Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Api V3 - Styling countries or cities

I am trying to make a map, just for selected area, lets say country, and get rid of some of the labels and stuff that are on the map. I found a styles wizard: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html But my question is, if u can somehow hide smaller cities, or other countries than my selected one?

I know i can hide all cities at once, or that i can hide borders, but i am curious if i can leave main cities visible, and for example gray out other countries than USA or i would have to manually create biggest polygon ever everywhere except USA? o.o

like image 403
Kedor Avatar asked Oct 10 '11 14:10

Kedor


People also ask

How do you highlight an area city state or country on Google Maps?

To see it yourself, go to Google Maps and search for a city name or even a zip code. You will see a pinkish highlight around the border. Based on your zoom level, as you zoom out, Google will highlight the whole area, not just the borders, in the pink color.

Can you style Google Maps API?

The Google Maps APIs now support you in creating beautiful styled maps for your Android and iOS apps as well as your website using the same JSON style object.

Why Google Maps might not look the same in different countries?

Next time you look at Google Maps, remember that it might not be as absolute as you thought. That's because Google shifts the borders between countries, depending on what country you are in when you look at them. That is, Google customizes its maps, depending on what the viewer expects to see.


1 Answers

Unfortunately, Google Maps API doesn't offer a way to selectively hide labels in an area. You can only remove labels for the whole map in several categories - e.g. using MapTypeStyle containing:

{
    featureType: "administrative.country",
    elementType: "labels",
    stylers: [
        { visibility: "off" }
    ]
}

hides labels with country names.

To hide an area you have to create your own overlay - some polygon or overlay map type.

When you want to show only an area of the map, it might be also a good idea to limit viewable area of the map.

like image 124
Tomik Avatar answered Oct 12 '22 17:10

Tomik