Skip to content

Instantly share code, notes, and snippets.

@nagaki
Created August 24, 2015 02:00
Show Gist options
  • Save nagaki/4880e16bd0c25d201aea to your computer and use it in GitHub Desktop.
Save nagaki/4880e16bd0c25d201aea to your computer and use it in GitHub Desktop.
Google Maps JavaScript APIのスタイルカスタム
var map;
window.initMap = function() {
var myLatLng = {
lat: <%= data.corp.latitude.value %>,
lng: <%= data.corp.longitude.value %>
};
var mapOptions = {
center: myLatLng,
zoom: 11,
panControl: false,
zoomControl: true,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
overviewMapControl: false
};
var styles = [
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": "-10"
},
{
"lightness": "0"
},
{
"hue": "#ffd700"
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#172435"
},
{
"visibility": "on"
}
]
}
];
map = new google.maps.Map(document.getElementById('map'), mapOptions);
map.setOptions({styles: styles});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: "The place"
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment