How can i center map to again the default position lat and lng dynamcaly
See original GitHub issueI have this code
import React from "react";
import ReactDOM from "react-dom";
import { compose, withProps } from "recompose";
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
Circle
} from "react-google-maps";
import config from 'config';
const GoogleMaps = compose(
withProps({
/**
* Note: create and replace your own key in the Google console.
* https://console.developers.google.com/apis/dashboard
* The key "AIzaSyBkNaAGLEVq0YLQMi-PYEMabFeREadYe1Q" can be ONLY used in this sandbox (no forked).
*/
googleMapURL:
"https://maps.googleapis.com/maps/api/js?key=" + config.googlemaps + "v=3.exp&libraries=geometry,drawing,places",
loadingElement: <div style={{ height: `100%` }} />,
containerElement: <div style={{ height: `300px` }} />,
mapElement: <div style={{ height: `100%` }} />
}),
withScriptjs,
withGoogleMap
)(props => (
<GoogleMap defaultZoom={8} defaultCenter={new google.maps.LatLng(props.lat, props.lng)}>
{props.isMarkerShown && (
<Marker position={{ lat: props.lat, lng: props.lng }} />
)}
{props.isCircle && (
<Circle radius={10000} visible={true} center={{ lat: props.lat, lng: props.lng }}/>
)}
</GoogleMap>
));
export { GoogleMaps };
after i have change the lat and lng props the element map stays on first position how to center it to the marker ?
Many thanks Carlos Vieira
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Google map API dynamic lat/lng initial center not showing ...
I get item lat/lng and set them to state, to use in maps. When I step through everything it is the correct lat:32.735962/lng:-96.275256...
Read more >Getting Lat/Lng from a Click Event | Maps JavaScript API
To navigate, press the arrow keys. Click the map to get Lat/Lng! zoom: 4, center: myLatlng,
Read more >Dynamic Google Maps
With the Dynamic Google Maps widget you can create an interactive map ... Latitude and Longitude ... The position on the map is...
Read more >Google Maps API - Map options, properties, controls
center. LatLng. Determines the initial center of the map. Required. Constructor : LatLng(lat:number, lng:number, noWrap?:boolean). Creates a ...
Read more >The Map component - Google Web Designer Help
Enter the Latitude and Longitude properties to set the default center point of the map. (Learn how to find the coordinates of a...
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 Free
Top 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
Solution found…
center={new google.maps.LatLng(props.lat, props.lng)}
thanks Carlos Vieira
@ShintaroNippon 100% worked this solution (If Radius not update) <Circle center={{ lat: item.lat, lng: item.lng }} radius={2000} visible={true} options={{ strokeColor: “#ff0000” }} />