react-leaflet-google icon indicating copy to clipboard operation
react-leaflet-google copied to clipboard

Zoom issue when passing styles to GoogleLayers

Open aqueiros opened this issue 7 years ago • 2 comments

Greetings,

I have the following working code which works fine:

import { Map, ZoomControl } from 'react-leaflet'
import { GoogleLayer} from 'react-leaflet-google';

export class MapContainer extends React.Component {
  (...)
  render() {
    return (
      <Map id="map" ref={this.mapRef} zoomControl={false}>
        <ZoomControl position="bottomright" />
        <GoogleLayer
          googlekey={my_key}
          maptype='ROADMAP'
        />
      </Map>
    );
  }
}

However, when I try to create a GoogleLayer with only labels like this:

import { Map, ZoomControl } from 'react-leaflet'
import { GoogleLayer} from 'react-leaflet-google';

export class MapContainer extends React.Component {
  (...)
  render() {
    return (
      <Map id="map" ref={this.mapRef} zoomControl={false}>
        <ZoomControl position="bottomright" />
        <GoogleLayer
          googlekey={my_key}
          maptype='ROADMAP'
          styles ={[
            {elementType: 'all', stylers: [{visibility: 'off'}]},
            {elementType: 'labels', stylers: [{visibility: 'on'}]},
          ]}
        />
      </Map>
    );
  }
}

I run into a problem with the zoom. After zooming out, and then zooming in again, I end up with a mix of labels from the previous zoom and the new one:

screenshot 2018-11-05 15 01 50

This clears out, after I do one or two more zoom ins

I'm using [email protected] [email protected] [email protected]

Anyone experienced this before?

Thank you!

EDIT:

This is reproducible event if I try disabling only landscape features:

styles ={[ 
     {featureType:"landscape", stylers: [{visibility: 'off'}]},
]}

screenshot 2018-11-05 15 54 19

aqueiros avatar Nov 05 '18 13:11 aqueiros

Hi @aqueiros, very interesting.

Have you try it, without using react-leaflet? just leaflet and google maps

Charmatzis avatar Nov 09 '18 08:11 Charmatzis

@Charmatzis I was holding on until I did a bit more testing, but It looks like I worked around it by setting keepBuffer to 0

<GoogleLayer
     googlekey={my_key}
     maptype='ROADMAP'
     styles ={[
       {featureType:"landscape", stylers: [{visibility: 'off'}]},
     ]}
     keepBuffer={0}
/> 

aqueiros avatar Nov 09 '18 09:11 aqueiros