Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
Is there a way to get the coordinates from this draggable marker using google-map-react?

I have made the marker so it is draggable on the map. I am trying to get the coordinates from the marker though so I can save them into my database. Below is the code , is there a function that I can get the coordinates from when the marker has been dragged. Or should I use another google maps react library.

import React, {Component, useCallback} from "react";
import GoogleMapReact from "google-map-react";

class Map extends Component {
  loadMap = (map, maps) => {

    let marker = new maps.Marker({
      position: { lat: 40.856795, lng: -73.954298 },
      map,
      draggable: true,

    });
  };
  

  render() {
    return (
      <div style={{ height: "400px", width: "100%" }}>
        <GoogleMapReact
          bootstrapURLKeys={{ key: "key here" }}
          defaultCenter={{ lat: 40.756795, lng: -73.954298 }}
          defaultZoom={10}
          yesIWantToUseGoogleMapApiInternals
          onGoogleApiLoaded={({ map, maps }) => this.loadMap(map, maps)}

        >
        </GoogleMapReact>
      </div>
    );
  }
}

export default Map;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are using the google api for the marker so you can use the marker docs.

Specifically you should use the dragend event

Something like

handleDragEnd = (event) => {
  console.log(event.latLng);
}

loadMap = (map, maps) => {
  let marker = new maps.Marker({
    position: { lat: 40.856795, lng: -73.954298 },
    map,
    draggable: true,
  });
  marker.addListener('dragend', this.handleDragEnd);
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda