question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Map doesn't render markers on initial load and Cluster Markers disappearing.

See original GitHub issue

I am using the library to show markers from Mobx Data store but the markers don’t show unless I have changed the source file and the UI is updated by HotModuleReplacement. Hopefully, I can get a solution as the library is Great!!

Here is my Map Comp:

@inject("map") @observer
export default class Map extends Component {

    constructor(props) {
        super(props);
    }

    render() {
        const mapStore = this.props.map

        const GettingStartedGoogleMap = withGoogleMap((props) => (
            <GoogleMap
                style={{
                    height: 100,
                    width: 100,
                }}
                onIdle={props.onIdle}
                onBoundsChanged={props.onBoundsChanged}
                defaultOptions={{ styles: this.mapStyles }}
                defaultZoom={mapStore.zoom}
                defaultCenter={{ lat: mapStore.center.lat, lng: mapStore.center.lng }}>
                {
                    props.markers.map((marker) => (
                        <Marker
                            position={marker}
                            icon={{
                                url: require('../../images/marker.png')
                            }}
                        />
                    ))
                }
            </GoogleMap>
        ))

        return (
            <GettingStartedGoogleMap
                style={{
                    height: 100,
                    width: 100,
                }}
                onIdle={() => {
                    mapStore.fetchMarkers()
                }}
                markers={this.props.map.markers}
                containerElement={
                    <div style={{ height: 'calc(100vh - 70px)' }
                    } />
                }
                mapElement={
                    <div style={{ height: 'calc(100vh - 70px)' }} />
                } />
        )
    }

    mapStyles = [MY MAPS STYLES]

}

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
NathHorrigancommented, May 5, 2017

Issue turned out to be related to MobX and I had to do this:

<GettingStartedGoogleMap
                style={{
                    height: 100,
                    width: 100,
                }}
                onMapLoad={() => {
                    mapStore.fetchMarkers()
                }}
                onBoundsChanged={() => {
                    mapStore.fetchMarkers()
                }}
                markers={mobx.toJS(this.props.map.markers)} // <------ HERE
                containerElement={
                    <div style={{ height: 'calc(100vh - 70px)' }
                    } />
                }
                mapElement={
                    <div style={{ height: 'calc(100vh - 70px)' }} />
                } />

Now I’m having problem with ClusterMarkers, When I zoom in they disappear. Normal Markers work fine without ClusterMarkers.

1reaction
MathieuChcommented, May 4, 2017

Could you paste the marker object from your store ? 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

React google maps Markers disappear after component re ...
First render of the page -> everything loads fine because everything gets rendered for the first time (including markers).
Read more >
Marker Clustering | Maps JavaScript API - Google Developers
This tutorial shows you how to use marker clusters to display a large number of markers on a map. You can use the...
Read more >
Changelog | MapSVG
Bugfix Incompatibility with WordPress 5.6; Bugfix Disappearing markers on Google Map after filtering; Bugfix Choropleth colors are incorrect if all regions ...
Read more >
Python folium markercluster doesn't work as expected for the ...
https://stackoverflow.com/questions/72222835/folium-put-markers-in-marker-clusters-and-in-layers-based-on-a-value.
Read more >
React Leaflet tutorial - LogRocket Blog
We'll show markers with custom icons and display a popup on the map when ... that the map renders itself into, otherwise it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found