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

111
Views
react-map-gl showUserHeading no en GeolocateControl

Estoy tratando de mostrar la posición de los usuarios y el indicador de rumbo en React-mapbox-gl.

 import * as React from "react"; import ReactMapGL, { GeolocateControl } from "react-map-gl"; const geolocateControlStyle = { right: 10, top: 10 }; function App() { const [viewport, setViewport] = React.useState({ longitude: -122.45, latitude: 37.78, zoom: 14 }); return ( <ReactMapGL {...viewport} width="80vw" height="80vh" onViewportChange={setViewport} mapboxApiAccessToken={ "<token here>" } > <GeolocateControl style={geolocateControlStyle} positionOptions={{ enableHighAccuracy: true }} trackUserLocation={true} auto /> </ReactMapGL> ); }

Actualmente solo tengo donde está el usuario, no su título actual.

posición sin encabezado

Lo que quiero es mostrar el encabezado actual, así:

posición con indicador de rumbo

Encontré la opción para agregar el indicador de encabezado en los documentos ( https://docs.mapbox.com/mapbox-gl-js/api/markers/#geolocatecontrol ), y hay una opción para mostrar el encabezado del usuario en el contenedor de reacción. ¿Y no puedo entender cómo agregar esta opción en el contenedor de reacción?

Aquí está la documentación de accesorios de GeoLocation: https://visgl.github.io/react-map-gl/docs/api-reference/geolocate-control

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

EDITAR: se lanzó v6.1.18, y GeolocateControl ahora tiene el accesorio showUserHeading. Por lo tanto, la solución a continuación ya no es necesaria.

Descubrí que a partir del 21.09.2021, react-map-gl no ha incluido showUserHeading dentro de sus accesorios. Resolví esto parcheando usando esta herramienta https://www.npmjs.com/package/patch-package

aquí está el parche

 diff --git a/node_modules/react-map-gl/src/components/geolocate-control.d.ts b/node_modules/react-map-gl/src/components/geolocate-control.d.ts index 7c5d2a4..949f38b 100644 --- a/node_modules/react-map-gl/src/components/geolocate-control.d.ts +++ b/node_modules/react-map-gl/src/components/geolocate-control.d.ts @@ -9,6 +9,7 @@ type GeolocateControlProps = MapControlProps & Partial<{ positionOptions: any, fitBoundsOptions: any, trackUserLocation: boolean, + showUserHeading?: boolean, showUserLocation: boolean, showAccuracyCircle: boolean, onViewStateChange?: Function,
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!