Skip to content

Instantly share code, notes, and snippets.

@ascoppa
Last active August 29, 2015 14:15
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 ascoppa/bd6e8426c4c695008c2e to your computer and use it in GitHub Desktop.
Save ascoppa/bd6e8426c4c695008c2e to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>A static map with a polygon</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css' rel='stylesheet' />
</head>
<body>
<div id='map'></div>
<script>
//cordinates are [lng, lat]
//poligon.cordinates.first must be equal to poligon.cordinates.last
var polygon = {
"type":"FeatureCollection",
"features":[{ "type":"Feature","properties":{"stroke": "#68B9AB", "fill": "#68B9AB"},
"geometry":{ "type":"Polygon",
"coordinates":[[
[-122.460909,37.803477],
[-122.436018,37.807207],
[-122.426062,37.806732],
[-122.417307,37.805105],
[-122.405891,37.806665],
[-122.387867,37.789302],
[-122.388725,37.780484],
[-122.390528,37.777024],
[-122.389069,37.766915],
[-122.395334,37.758026],
[-122.403917,37.74934],
[-122.422543,37.747915],
[-122.430439,37.747508],
[-122.435331,37.762844],
[-122.445803,37.771936],
[-122.450266,37.791337],
[-122.460909,37.803477]
]]
}
}]
}
var geojson = "geojson("+JSON.stringify(polygon)+")";
var your_public_key = "";
var src = "http://api.tiles.mapbox.com/v4/mapbox.emerald/"+
encodeURIComponent(geojson)+
"/auto/800x400.png?access_token="+your_public_key;
$("#map").html("<img src='"+src+"'>");
</script>
</body>
</html>