Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
geojson no se renderiza en mapbox

Aquí estoy usando la geocodificación inversa. Estoy tratando de representar el mapa de la ubicación del usuario enviando la latitud y la longitud a la API de geocodificación inversa, pero no está representando solo las coordenadas iniciales utilizadas como centro.

 import ReactDOM from "react-dom"; import React, { useRef, useEffect, useState } from "react"; import mapboxgl from "mapbox-gl"; import "./map.css"; mapboxgl.accessToken = process.env.REACT_APP_MAPBOX_ACCESS_TOKEN; function Map() { const [mapData, setMapdata] = useState(null); const mapContainerRef = useRef(null); const popUpRef = useRef(new mapboxgl.Popup({ offset: 15 })); // initialize map when component mounts useEffect(() => { const map = new mapboxgl.Map({ container: mapContainerRef.current, // See style options here: https://docs.mapbox.com/api/maps/#styles style: "mapbox://styles/mapbox/streets-v11", center: [85, 27], // starting position zoom: 12.5, }); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { map.on("load", function () { map.addSource("myLocation", { type: "geojson", // Use a URL for the value for the `data` property. data:`https://api.mapbox.com/geocoding/v5/mapbox.places/${position.coords.latitude}, ${position.coords.longitude}.json? access_token=${process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}` }); }); }); } // clean up on unmount return () => map.remove(); }, []); return <div className="map-container" ref={mapContainerRef} />; } export default Map;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que olvidaste agregar la fuente de datos a una capa. Para mostrar una fuente, debe agregar una capa y establecer el atributo de source en su fuente de datos.

Intente agregar algo a lo largo de las líneas de:

 map.addLayer({ id: 'locations', source: 'myLocation', // everthing beyond this point is styling/customization type: 'circle', paint: { 'circle-color': '#ff0000', 'circle-radius': 6, 'circle-stroke-width': 2, 'circle-stroke-color': '#fff' } });

Puede encontrar más información sobre las capas, incluido el estilo y la personalización aquí: https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!