Skip to content

Instantly share code, notes, and snippets.

@veltman
Created February 1, 2014 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veltman/8746057 to your computer and use it in GitHub Desktop.
Save veltman/8746057 to your computer and use it in GitHub Desktop.
//Initialize the map
var map = L.map('map',{center: [37.18,-121.72], zoom: 12, drawControl: true, minZoom: 10,maxZoom: 18});
//terrain, terrain-lines, toner-lite, toner, watercolor
L.tileLayer(
'https://mts1.google.com/vt/lyrs=m@231165345&hl=en&src=app&x={x}&y={y}&z={z}&apistyle=s.t%3A2%7Cp.s%3A-100%7Cp.v%3Aoff%2Cp.s%3A-100%7Cp.l%3A14%2Cs.t%3A49%7Cp.v%3Asimplified%7Cp.l%3A15%2Cs.t%3A4%7Cp.v%3Aoff%2Cs.t%3A6%7Cp.l%3A-8&style=47,37%7Csmartmaps',
{
subdomains: 'abcd'
}).addTo(map);
var polyBig = L.polygon(
[[37.1631894028733,-121.8016423919471],[37.20107352332477,-121.78945443418344],[37.22322077240998,-121.72834298398811],[37.18110808791507,-121.66997811582405],[37.14950815762241,-121.73709771421272]],
{color: "red", opacity: 1, fillOpacity: 1});
var polySmall = L.polygon(
[[37.17262801853344,-121.76267525937874],[37.20080005987362,-121.75426385190804],[37.191911958397284,-121.71443841245492],[37.1719441004939,-121.72044656064827],[37.1631894028733,-121.74533746030649]],
{color: "blue", opacity: 1, fillOpacity: 1});
//Add red
map.addLayer(polyBig);
//Add blue
map.addLayer(polySmall);
//Blue is now above red
polyBig.bringToFront();
//Red is now above blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment