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