Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1117·google-map-react

Markers flicker when scrolling on the map

Author: CrissAlvarezHCreated May 28, 2022Updated Dec 31, 2025

When the map is scrolled and the mouse is released, the markers blink from where they were initially positioned.

The code

bash
import React from "react";
import GoogleMapReact from 'google-map-react';


const AnyReactComponent = ({ text }) => (
    <div style={{
        width: "70px",
        backgroundColor: "black",
        color: "white",
        padding: 2,
        textAlign: "center"
    }}>
        {text}
    </div>
);

const center =     {
    lat: 8.789109769101659,
    lng: -75.85785616189241,
}

const zoom = 17

export default function SimpleMap(){
  console.log("simple map render")
  return (
    <div style={{ height: '100vh', width: '100%' }}>
      <GoogleMapReact
        bootstrapURLKeys={{ key: THE_KEY }}
        defaultCenter={center}
        defaultZoom={zoom}
      >
        <AnyReactComponent
            lat={center.lat}
            lng={center.lng}
            text="My Marker"
            />
      </GoogleMapReact>
    </div>
  );
}

**Screenshots ** IMPORTANT: It always happens, in this gif it only happens the first two times, but it's because when converting video to gif the quality drops

ezgif com-gif-maker

Environment:

  • OS: windows
  • Browser chrome, mozilla, etc.
  • google-map-react: 2.1.10
  • react 18.1.0

Source: google-map-react/google-map-react

View original on GitHubView discussion on GitHub