Hat-tip to Ivan Sanchez's Leaflet.GridLayer.GoogleMutant.
Created
January 11, 2017 00:03
-
-
Save zbeat/12bdc5336b881feb9b084ebe54c4a6ac to your computer and use it in GitHub Desktop.
Google Maps tiles w/ Leaflet JS (via GoogleMutant) -- STYLED MAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Google Maps tiles w/ Leaflet JS (via GoogleMutant)</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="http://unpkg.com/[email protected]/dist/leaflet.css" /> | |
<script src="http://unpkg.com/[email protected]/dist/leaflet-src.js"></script> | |
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDm9FChxIfXD9i63TsTYmrkE8IBbzuyVTM" async defer></script> | |
<script src="http://unpkg.com/leaflet.gridlayer.googlemutant@latest/Leaflet.GoogleMutant.js"></script> | |
<style> | |
#map { | |
/* margin: 32px; */ | |
/* width: auto; */ | |
/* overflow: visible; */ | |
width: calc( 100vw - 64px); | |
height: calc( 100vh - 64px); | |
} | |
body { | |
margin: 0 | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map" class="map"></div> | |
<script type="text/javascript"> | |
var mapopts = { | |
// zoomSnap: 0.1 | |
}; | |
var latLng = L.latLng(41.31, -72.93); | |
var zoom = 12; | |
var map = L.map("map", mapopts).setView(latLng, zoom); | |
var styles = [ | |
{ elementType: "labels", stylers: [ { visibility: "on" } ] }, | |
{ featureType: "water", stylers: [ { color: "#444444" } ] }, | |
{ featureType: "landscape", stylers: [ { color: "#eeeeee" } ] }, | |
{ featureType: "road", stylers: [ { visibility: "off" } ] }, | |
{ featureType: "poi", stylers: [ { visibility: "off" } ] }, | |
{ featureType: "transit", stylers: [ { visibility: "off" } ] }, | |
{ featureType: "administrative", stylers: [ { visibility: "off" } ] }, | |
{ featureType: "administrative.locality", stylers: [ { visibility: "on" } ] } | |
]; | |
// var styles = []; | |
var mutantMap = L.gridLayer.googleMutant({ | |
// minZoom: 10, | |
// maxZoom: 20, | |
type: "roadmap", // valid values: "roadmap", "satellite", "terrain", "hybrid", | |
styles: styles | |
}) | |
mutantMap.addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment