Marker showed twice
cinder92 opened this issue · comments
After following the documentation im getting a weird behavior, which the map is rendering two markers, and the map has only one marker
import React from 'react';
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
} from 'react-google-maps';
import { config } from '../settings';
const GoogleMaps = withScriptjs(
withGoogleMap(props => (
<GoogleMap defaultZoom={8} defaultCenter={{ lat: -34.397, lng: 150.644 }}>
{props.isMarkerShown && (
<Marker draggable position={{ lat: -34.397, lng: 150.644 }} />
)}
</GoogleMap>
))
);
const Map = () => {
return (
<GoogleMaps
googleMapURL={`https://maps.googleapis.com/maps/api/js?key=${config.GOOGLE_MAPS_API_KEY}&v=3.exp&libraries=geometry,drawing,places`}
loadingElement={<div style={{ height: `100%` }} />}
containerElement={<div style={{ height: `300px` }} />}
mapElement={<div style={{ height: `100%` }} />}
isMarkerShown
/>
);
};
export default Map;
Note,that i dragged the marker just to show the issue
@cinder92 The repo of this project is unmaintained more than a 2 years, and we had build new version https://www.npmjs.com/package/@react-google-maps/api
We had rewrite it to TypeScript, and updating it frequently: https://github.com/JustFly1984/react-google-maps-api/tree/master/packages/react-google-maps-api
You can enjoy autocomplete.
You can see our docs: https://react-google-maps-api-docs.netlify.app
Also a lot of examples: https://react-google-maps-api-gatsby-demo.netlify.app/ https://github.com/JustFly1984/react-google-maps-api/tree/master/packages/react-google-maps-api-gatsby-example/src/examples
The bundle size is much smaller: https://bundlephobia.com/result?p=@react-google-maps/api
Our Spectrum community: https://spectrum.chat/react-google-maps Our Slack channel: https://join.slack.com/t/react-google-maps-api/shared_invite/enQtODc5ODU1NTY5MzQ4LTBiNTYzZmY1YmVjYzJhZThkMGU0YzUwZjJkNGJmYjk4YjQyYjZhMDk2YThlZGEzNDc0M2RhNjBmMWE4ZTJiMjQ
Enjoy!
@JustFly1984 Please mention it on the repository's main page. It may help other users.
@shivamjjha I have no contact with developer of this package, nor I have ability to change code. That is downside of open source software. That is why I had to fork this lib 2 years ago.
hey @JustFly1984 can you look at my code and see what's wrong. The marker is shown twice. I don't want to write the whole code again by some other library. If you could please have a look at it. Thanks.
@shivamjjha I do not support this library. It is not maintained more than 3 years. Please consider to switch to my new version.