You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by "leonardcser (via GitHub)" <gi...@apache.org> on 2023/05/04 08:01:30 UTC

[GitHub] [incubator-baremaps-site] leonardcser opened a new pull request, #23: Feature/apis

leonardcser opened a new pull request, #23:
URL: https://github.com/apache/incubator-baremaps-site/pull/23

   - Add geocoder search component (`http://demo.baremaps.com/api/geocoder?queryText=${queryText}`)
   - Add iptoloc on map load (`http://demo.baremaps.com/api/ip/${ip}`)
   - Add new icon title component for homepage
   - Add content for geocoder on the home page


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps-site] bchapuis commented on a diff in pull request #23: Feature/apis

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps-site] bchapuis merged pull request #23: Feature/apis

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
bchapuis merged PR #23:
URL: https://github.com/apache/incubator-baremaps-site/pull/23


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org