tomchentw / react-google-maps

React.js Google Maps integration component
https://tomchentw.github.io/react-google-maps/
MIT License
4.62k stars 939 forks source link

Marker showed twice #1051

Open cinder92 opened 4 years ago

cinder92 commented 4 years ago

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;

Captura de Pantalla 2020-06-24 a la(s) 11 50 33

Note,that i dragged the marker just to show the issue

JustFly1984 commented 4 years ago

@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!

shivamjjha commented 3 years ago

@JustFly1984 Please mention it on the repository's main page. It may help other users.

JustFly1984 commented 3 years ago

@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.

shivamjjha commented 3 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.

Sandbox Link

JustFly1984 commented 3 years ago

@shivamjjha I do not support this library. It is not maintained more than 3 years. Please consider to switch to my new version.