Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Zoom issue when passing styles to GoogleLayers #31

Open
aqueiros opened this issue Nov 5, 2018 · 2 comments
Open

Zoom issue when passing styles to GoogleLayers #31

aqueiros opened this issue Nov 5, 2018 · 2 comments

Comments

@aqueiros
Copy link

aqueiros commented Nov 5, 2018

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
react-leaflet-google@3.3.1
react-leaflet@1.9.1
leaflet@1.3.1

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 aqueiros changed the title Zoom issue when using multiple GoogleLayers Zoom issue when using labels only GoogleLayers Nov 5, 2018
@aqueiros aqueiros changed the title Zoom issue when using labels only GoogleLayers Zoom issue when passing styles to GoogleLayers Nov 5, 2018
@Charmatzis
Copy link
Owner

Hi @aqueiros, very interesting.

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

@aqueiros
Copy link
Author

aqueiros commented Nov 9, 2018

@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}
/> 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants