Skip to content

Instantly share code, notes, and snippets.

@willemarcel
Created March 30, 2019 16:05
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 willemarcel/d6152bc7d0638f8463eecc43e6b510ac to your computer and use it in GitHub Desktop.
Save willemarcel/d6152bc7d0638f8463eecc43e6b510ac to your computer and use it in GitHub Desktop.
test map campaigner visualization with Leaftlet.VectorGrid
<!DOCTYPE html>
<html>
<head>
<title>Quick Start - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js" integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg==" crossorigin=""></script>
<script type="text/javascript" src="https://unpkg.com/leaflet.vectorgrid@1.2.0"></script>
</head>
<body>
<div id="mapid" style="width: 600px; height: 400px;"></div>
<script>
var mymap = L.map('mapid').setView([-23.55143, -46.67923], 13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(mymap);
// 'http://localhost:5000/tiles/{z}/{x}/{y}.pbf',
L.vectorGrid.protobuf(
'https://s3-us-west-2.amazonaws.com/hotosm-fieldcampaigner-data-staging/campaigns/9386a612e0b64909875f3e30a22fe123/render/buildings/tiles/{z}/{x}/{y}.pbf',
{
vectorTileLayerStyles: {
buildings: {
fill: true,
weight: 1,
fillColor: "#2b2b2b",
color: "#2b2b2b",
fillOpacity: 1,
opacity: 1
}
},
maxNativeZoom: 19
}
).addTo(mymap);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment