|
|
@ -1,4 +1,4 @@ |
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
import React, { useState } from "react"; |
|
|
|
import { View } from "react-native"; |
|
|
|
import WebView from "react-native-webview"; |
|
|
|
import { |
|
|
@ -11,10 +11,10 @@ import { |
|
|
|
function bindEventsToListeners(event, clickListener, markerListener) { |
|
|
|
switch (event.object) { |
|
|
|
case "click": |
|
|
|
clickListener(event.cords); |
|
|
|
clickListener && clickListener(event.cords); |
|
|
|
break; |
|
|
|
case "marker": |
|
|
|
markerListener(event.id); |
|
|
|
markerListener && markerListener(event.id); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
@ -22,7 +22,6 @@ function bindEventsToListeners(event, clickListener, markerListener) { |
|
|
|
} |
|
|
|
|
|
|
|
export default function OpenStreetMap({ |
|
|
|
initialRegion, |
|
|
|
markersList, |
|
|
|
animateToPosition, |
|
|
|
clickListener, |
|
|
@ -32,13 +31,13 @@ export default function OpenStreetMap({ |
|
|
|
const [webviewContent, setWebviewContent] = useState(null); |
|
|
|
|
|
|
|
if (mapRef != null) { |
|
|
|
initialRegion != null && goToRegion(mapRef, initialRegion); |
|
|
|
|
|
|
|
animateToPosition != null && goToRegion(mapRef, animateToPosition); |
|
|
|
|
|
|
|
markersList != null && |
|
|
|
markersList.length > 0 && |
|
|
|
markersList.map(({ ID, cords }) => insertMarker(mapRef, ID, cords)); |
|
|
|
markersList.map(({ ID, cords, icon }) => |
|
|
|
insertMarker(mapRef, ID, cords, icon) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
loadHTMLFile() |
|
|
|