bchapuis commented on code in PR #23:
URL: 
https://github.com/apache/incubator-baremaps-site/pull/23#discussion_r1184844604


##########
src/components/map/index.tsx:
##########
@@ -4,47 +4,85 @@ import MaplibreInspect from 
'@/lib/maplibre/dist/maplibre-gl-inspect/maplibre-gl
 import MaplibreTileBoundaries from 
'@/lib/maplibre/dist/maplibre-gl-tile-boundaries/maplibre-gl-tile-boundaries';
 
 import styles from './style.module.css';
+import { GeocoderSearch } from '../GeocoderSearch';
 
-export default function Map() {
+interface MapProps {
+  longitude?: number;
+  latitude?: number;
+  zoom?: number;
+  ipToLoc?: boolean;
+}
+
+export default function Map({
+  longitude = 6.625,
+  latitude = 46.51,
+  zoom = 14,
+  ipToLoc = true
+}: MapProps) {
   const mapContainer = useRef(null);
-  const map = useRef(null);
-  const [lng] = useState(6.625);
-  const [lat] = useState(46.51);
-  const [zoom] = useState(14);
+  const [map, setMap] = useState(null);
 
+  // Initialize map when component mounts
   useEffect(() => {
-    if (map.current) return;
-    map.current = new maplibregl.Map({
-      container: mapContainer.current,
-      style: `https://demo.baremaps.com/style.json`,
-      center: [lng, lat],
-      zoom: zoom
-    });
-    map.current.addControl(new maplibregl.NavigationControl({}));
-
-    // Add the inspect control to the map.
-    map.current.addControl(
-      new MaplibreInspect({
-        showMapPopup: true,
-        showMapPopupOnHover: false,
-        showInspectMapPopupOnHover: false,
-        popup: new maplibregl.Popup({
-          closeButton: true,
-          closeOnClick: true
+    const initMap = async () => {
+      if (ipToLoc) {
+        try {
+          const res = await fetch('https://api.ipify.org/?format=json');

Review Comment:
   The ip address should be extracted by the ip to location service or by the 
browser (not by a third-party service). This issue has been logged in baremaps:
   
   https://github.com/apache/incubator-baremaps/issues/640



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to