onDragend and getting the new LatLng of the center of the map
See original GitHub issueI’ve a basic map…
<Map
google={google}
zoom={13}
style={mapStyles}
initialCenter={userCoordinates}
onClick={this.onMapClick}
styles={style}
onDragend={this.centerMoved}
/>
thing to note is the onDragend property… I have it mapped to fire this.centerMoved… which is defined as such. I can’t seem to figure out how to get the new map’s Lat and Lng at this point…
centerMoved = (mapProps, map) => {
console.log(mapProps.google.maps.LatLng()); // returns undefined
};
Is there any way to get this information? Am I using the wrong event?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
How to get lat, long after map dragend - Stack Overflow
The map dragend event callback function doesn't have any arguments. Inside the callback function, get the map center (which is what you want):...
Read more >Getting Lat/Lng from a Click Event | Maps JavaScript API
This example listens for the click event, gets the latitude and longitude ... infoWindow = new google.maps.InfoWindow({ position: mapsMouseEvent.latLng, });
Read more >Google Maps Reference - W3Schools
The Map() constructor creates a new map inside a specified HTML element (typically a ... getCenter(), LatLng, Returns the lat/lng of the center...
Read more >Getting coordinates from click or drag event in Google Maps ...
getElementById('mapCanvas'), { zoom: 8, center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP }); var marker = new google.maps.Marker({ position: latLng ...
Read more >How to Get formatted Address, Latitude, and Longitude from ...
How to Get formatted Address, Latitude, and Longitude from Dragged ... How to create a draggable marker on Google Map ... center: myLatlng,....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@matgargano your center moved function should be like this: