Skip to content

Instantly share code, notes, and snippets.

@sn0opy
Last active February 18, 2020 15:49
Show Gist options
  • Select an option

  • Save sn0opy/1f01cbfa769027883b7394952eb1fb36 to your computer and use it in GitHub Desktop.

Select an option

Save sn0opy/1f01cbfa769027883b7394952eb1fb36 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8">
<title>Portal Map</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.css" />
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
}
#map {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js" integrity="sha256-T/f7Sju1ZfNNfBh7skWn0idlCBcI3RwdLSS4/I7NQKQ=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.js"></script>
<script src="https://robertleeplummerjr.github.io/Leaflet.glify/glify.js"></script>
<script>
function getcolor() {
return {
r: 255,
g: 0,
b: 0
};
}
(async function() {
var map = L.map('map', {
renderer: L.canvas(),
preferCanvas: true,
updateWhenZooming: false
}).setView([51.505, -0.09], 8);
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png').addTo(map);
var markers = [];
var res = await axios.get("/data"); // [{"lat": 51.123, "lon": 10.123"}]
for (portal of res.data) {
markers.push([parseFloat(portal.lat), parseFloat(portal.lon)]);
}
L.glify.points({
map: map,
fragmentShaderSource: L.glify.shader.fragment.point,
color: getcolor(),
size: 2,
opacity: 0.8,
data: markers
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment