diff --git a/app/client/src/components/designSystems/appsmith/MapComponent.tsx b/app/client/src/components/designSystems/appsmith/MapComponent.tsx index 80fa6067b6..09282d6df8 100644 --- a/app/client/src/components/designSystems/appsmith/MapComponent.tsx +++ b/app/client/src/components/designSystems/appsmith/MapComponent.tsx @@ -73,62 +73,80 @@ const PickMyLocationWrapper = styled.div` `; const MyMapComponent = withScriptjs( - withGoogleMap((props: any) => ( - { - if (props.enableCreateMarker) { - props.saveMarker(e.latLng.lat(), e.latLng.lng()); + withGoogleMap((props: any) => { + const [mapCenter, setMapCenter] = React.useState< + | { + lat: number; + lng: number; + title?: string; + description?: string; } - }} - > - {props.enableSearch && ( - - - - )} - {props.markers.map((marker: any, index: number) => ( - ({ + ...props.center, + lng: props.center.long, + }); + return ( + { + if (props.enableCreateMarker) { + props.saveMarker(e.latLng.lat(), e.latLng.lng()); } - onClick={e => { - props.selectMarker(marker.lat, marker.long, marker.title); - }} - onDragEnd={de => { - props.updateMarker(de.latLng.lat(), de.latLng.lng(), index); - }} - /> - ))} - {props.enablePickLocation && ( - - - - )} - - )), + }} + > + {props.enableSearch && ( + + + + )} + {props.markers.map((marker: any, index: number) => ( + { + setMapCenter({ + ...marker, + lng: marker.long, + }); + props.selectMarker(marker.lat, marker.long, marker.title); + }} + onDragEnd={de => { + props.updateMarker(de.latLng.lat(), de.latLng.lng(), index); + }} + /> + ))} + {props.enablePickLocation && ( + + + + )} + + ); + }), ); class MapComponent extends React.Component {