Skip to content

Commit

Permalink
Fix summary tiles, almost feature parity with original pull request. …
Browse files Browse the repository at this point in the history
…Missing: hide summary tiles / geometry tiles on certain zoom levels.
  • Loading branch information
wildintellect committed Nov 8, 2012
1 parent 9223500 commit 6073af2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 64 deletions.
25 changes: 25 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ $(function() {
// }
// );
// map.addLayer(owlTiles);
// var summaryIcon = L.divIcon({
// html: '<h3>' + json.num_changesets + '</h3>',
// className: 'summary-tile',
// iconSize: [256, 256]
// });
// layer._markers.addLayer(L.marker(point, {icon: summaryIcon}));
var markersLayer = L.layerGroup();
map.addLayer(markersLayer);

var markers = new L.TileLayer.Marker(
'http://localhost:3000/summary/{z}/{x}/{y}'
);
markers.on('load', function() {
markersLayer.clearLayers();
_.each(markers._tiles, function(t) {
var count = t.data.num_changesets || 0;
var icon = L.divIcon({
html: '<h3>' + count + '</h3>',
className: 'summary-tile',
iconSize: [256, 256]
});
markersLayer.addLayer(L.marker(t.location, {icon: icon}));
});
});
map.addLayer(markers);

// Active state handling.
$('.nav-container a').click(function() {
Expand Down
1 change: 0 additions & 1 deletion geojson-tiles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Load tiled GeoJSON and merge into single geojson hash.
// Requires jQuery for jsonp.
L.TileLayer.GeoJSON = L.TileLayer.Data.extend({
_data: [],
// Retrieve data.
data: function() {
var geojson = {"type":"FeatureCollection","features":[]};
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script src='vendor/underscore-min.js'></script>
<script src='data-tiles.js'></script>
<script src='geojson-tiles.js'></script>
<script src='summary-tiles.js'></script>
<script src='marker-tiles.js'></script>
<script src='app.js'></script>
</head>

Expand Down
12 changes: 12 additions & 0 deletions marker-tiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Load data and track location of tiles.
L.TileLayer.Marker = L.TileLayer.Data.extend({
_addTile: function(tilePoint, container) {
console.log(tilePoint, this._getTilePos(tilePoint), this._getTilePos(tilePoint).subtract({x: 125, y: 125}));
var tile = {
data: null,
location: this._map.layerPointToLatLng(this._getTilePos(tilePoint).add({x: 125, y: 125}))

This comment has been minimized.

Copy link
@lxbarth

lxbarth Nov 8, 2012

@ppawel - This offset on tiles fixes #17 and #18

};
this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
this._loadTile(tile, tilePoint);
}
});
62 changes: 0 additions & 62 deletions summary-tiles.js

This file was deleted.

0 comments on commit 6073af2

Please sign in to comment.