Skip to content

Instantly share code, notes, and snippets.

@lxbarth
Created February 28, 2015 11:09
Show Gist options
  • Save lxbarth/6a3c1842c8357cf5332f to your computer and use it in GitHub Desktop.
Save lxbarth/6a3c1842c8357cf5332f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>A simple map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<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' />
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-hash/v0.2.1/leaflet-hash.js'></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/turf/v1.4.0/turf.min.js'></script>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoibHhiYXJ0aCIsImEiOiJFVXdYcUlvIn0.bbaHTEWlnAwGgyVwJngMdQ';
var map = L.mapbox.map('map', 'examples.map-i86nkdio')
.setView([12.9550, 77.7242], 11)
.addControl(L.mapbox.geocoderControl('mapbox.places', {autocomplete: true}));
var hash = L.hash(map);
var points = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
77.51884460449219,
13.03131768257082
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
77.64930725097656,
13.046703337153815
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
77.6898193359375,
12.942998943409737
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
77.6019287109375,
12.902174394671018
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
77.49824523925781,
12.955044255275915
]
}
}
]
};
var hull = turf.convex(points);
var result = {
type: "FeatureCollection",
features: [hull, points]
}
var featureLayer = L.mapbox.featureLayer(result).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment