SymbolixAU / googleway

R Package for accessing and plotting Google Maps
http://symbolixau.github.io/googleway/
Other
234 stars 46 forks source link

Remove labels? #246

Closed camerynbrock closed 2 years ago

camerynbrock commented 2 years ago

This package is great! I was wondering if it is possible to remove reference labels (i.e., the strings denoting the cities/states/etc.), or to give them a separate z_index to put on top of polygons/overlays? This would be very helpful if so.

Thank you!

dcooley commented 2 years ago

Are you referring to something similar to their example where you can show / hide (buttons in the top left corner of the map) feature labels?

camerynbrock commented 2 years ago

Hi, thanks for your quick response. That doesn't look like what I mean - what I mean is similar to the option for toggling off and on labels when using the satellite background.

image

image

I am looking for a terrain basemap without labels or the option to put the labels on top of other layers. The reason is because I am using add_overlay to add an image over the map, so the labels beneath the overlay are cut off or not visible at all (screenshots here are from the google maps platform site).

image

dcooley commented 2 years ago

Oh I see. I'm not sure I've seen that functionality anywhere in the google maps docs, so I don't know off the top of my head if it's possible or not.

camerynbrock commented 2 years ago

Aha - figured this out if anyone else ends up being interested. Used styles code from https://mapstyle.withgoogle.com/

google_map(key = mapKey)

image

style <- '[{"elementType": "labels", "stylers": [{"visibility": "off"}]},
  {"featureType": "administrative.neighborhood", "stylers": [{"visibility": "off"}]},
  {"featureType": "road", "stylers": [{"visibility": "off"}]}]'

google_map(key = mapKey,
           styles = style)

image

dcooley commented 2 years ago

Does this approach allow you

the option to put the labels on top of other layers

?