Skip to content

Commit

Permalink
Track "current location" and show as a blue dot. Addresses #49.
Browse files Browse the repository at this point in the history
The blue dot won't dynamically update, but I prefer it to the flag.
Current location is also necessary to address #74.
  • Loading branch information
caywood committed Feb 3, 2012
1 parent 80356ae commit 8fdac69
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Binary file added tnm/client/static/images/ledlightblue_16px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tnm/client/static/images/ledlightblue_48px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion tnm/client/static/tnm.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ $(function() {

var geolocate = function() {
Transit.tryGeolocating(
function(latlng) { map.center(latlng); },
function(latlng) {
Transit.current.set = true;
Transit.current.location = latlng;
map.center(latlng);
},
function(error) { map.center(); });
}

Expand Down
21 changes: 21 additions & 0 deletions tnm/client/static/transit.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,26 @@ Transit._leafletMap.prototype.overlay = function(overlayID, overlay) {
stop.layer = stop_marker;
layers.addLayer(stop_marker);
}

// Build current location marker
if (Transit.current && Transit.current.set) {
var icon = new Transit._leafletMap.CurrentIcon(),
current_marker = new L.Marker(Transit.current.location, {icon : icon}),
popup_content = '<h3><br>Current<br>location</h3>';
current_marker.bindPopup(popup_content);
layers.addLayer(current_marker);
}

oldLayer && this.map.removeLayer(oldLayer);
this.layers[overlayID] = layers;
this.hiddenLayers[overlayID] = [];
this.map.addLayer(layers);
}

Transit.current = new Object();
Transit.current.set = false;
Transit.current.location = new L.LatLng(0, 0);

Transit._leafletMap.prototype.radius = function(latlng, radius_m) {
var radius = this.layers['radius'];
if (radius) {
Expand All @@ -427,3 +440,11 @@ Transit._leafletMap.TransitIcon = L.Icon.extend({
iconAnchor: new L.Point(13, 13),
popupAnchor: new L.Point(0, 0)
});

Transit._leafletMap.CurrentIcon = L.Icon.extend({
iconUrl: '/static/images/ledlightblue_16px.png',
shadowUrl: '',
iconSize: new L.Point(16, 16),
iconAnchor: new L.Point(13, 13),
popupAnchor: new L.Point(0, 0)
});

0 comments on commit 8fdac69

Please sign in to comment.