Skip to content

Instantly share code, notes, and snippets.

@erwaller
Last active August 29, 2015 13:57
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 erwaller/9650673 to your computer and use it in GitHub Desktop.
Save erwaller/9650673 to your computer and use it in GitHub Desktop.
SeatGeek Map with Simple Vector Layer

Here's a pretty minimal example of layering vector data on a SeatGeek map using Leaflet. In the interest of not making the example overwhelming, I'm only rendering a few features.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.6.4/leaflet.css">
</head>
<body>
<div id="map" style="position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.6.4/leaflet.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
<script>
L.CRS.SeatGeek = L.extend({}, L.CRS.Simple, {
transformation: new L.Transformation(0.35, 0, 0.35, 0)
});
var mapId = "v3-5-9.mlb";
var map = L.map("map", {
crs: L.CRS.SeatGeek,
center: [500, 500],
zoom: 1
});
L.tileLayer("https://seatgeek-tiles.global.ssl.fastly.net/v3/maps/{mapId}/{z}/{x}/{y}.png", {
mapId: mapId,
tileSize: 350,
maxZoom: 4,
noWrap: true
}).addTo(map);
$.get("https://seatgeek-tiles.global.ssl.fastly.net/v3/maps/" + mapId + ".json", function (data) {
// Only draw the first few features
data.features.features = data.features.features.slice(0, 10);
L.geoJson(data.features, {
style: {
color: "#ff0000",
"weight": 2
}
}).addTo(map);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment