Reputation: 396
As you know all the names of the large cities with big population are displayed with the large font size and all the names of the small towns are displayed with the small font size. How can I hide all the names of small towns with little population on the map at my website by using API Google Maps?
Upvotes: 4
Views: 14793
Reputation: 161334
from the styled map wizard, turn off the "Labels" for neighborhood, locality and parcel:
[
{
"featureType": "administrative.neighborhood",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "administrative.land_parcel",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "administrative.locality",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
}
]
code snippet:
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{
"featureType": "administrative.neighborhood",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.locality",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {}]
});
}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map_canvas" style="border: 2px solid #3872ac;"></div>
Upvotes: 7