Browse Source

Blocking links in references of LeafLet to open inside the app webview.

Now, it opens in user's defalut browser.
master
GabrielTrettel 3 years ago
parent
commit
8489cb2880
  1. 12
      src/app/components/map/OpenStreetMap.js

12
src/app/components/map/OpenStreetMap.js

@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { View } from "react-native";
import { View, Linking } from "react-native";
import WebView from "react-native-webview"; import WebView from "react-native-webview";
import { import {
setViewCode, setViewCode,
@ -56,8 +56,6 @@ export default function OpenStreetMap({
renderOptions: dataOptionsToShow, renderOptions: dataOptionsToShow,
}); });
// console.log(markersList)
useEffect(() => { useEffect(() => {
if (markersList && mapRef) { if (markersList && mapRef) {
deleteAllMarkers(mapRef); deleteAllMarkers(mapRef);
@ -91,7 +89,13 @@ export default function OpenStreetMap({
javaScriptEnabled={true} javaScriptEnabled={true}
source={{ html: webviewContent }} source={{ html: webviewContent }}
injectedJavaScript={viewFunction} injectedJavaScript={viewFunction}
onShouldStartLoadWithRequest={(event) => {
if (event.url.slice(0, 4) === "http") {
Linking.openURL(event.url);
return false;
}
return true;
}}
/> />
)} )}
{!isForm && ( {!isForm && (

Loading…
Cancel
Save