Skip to content

Commit

Permalink
fix geolocation accuracy bounds, add more event data, close #984, rel…
Browse files Browse the repository at this point in the history
…ated #584, #987, #1028
  • Loading branch information
mourner committed Feb 21, 2013
1 parent e87e010 commit 5558987
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/map/ext/Map.Geolocation.js
Expand Up @@ -60,13 +60,13 @@ L.Map.include({
},

_handleGeolocationResponse: function (pos) {
var latAccuracy = 180 * pos.coords.accuracy / 4e7,
lngAccuracy = latAccuracy * 2,

lat = pos.coords.latitude,
var lat = pos.coords.latitude,
lng = pos.coords.longitude,
latlng = new L.LatLng(lat, lng),

latAccuracy = 180 * pos.coords.accuracy / 40075017,
lngAccuracy = latAccuracy / Math.cos(L.LatLng.DEG_TO_RAD * lat),

sw = new L.LatLng(lat - latAccuracy, lng - lngAccuracy),
ne = new L.LatLng(lat + latAccuracy, lng + lngAccuracy),
bounds = new L.LatLngBounds(sw, ne),
Expand All @@ -78,10 +78,11 @@ L.Map.include({
this.setView(latlng, zoom);
}

this.fire('locationfound', {
var event = L.extend({
latlng: latlng,
bounds: bounds,
accuracy: pos.coords.accuracy
});
bounds: bounds
}, pos.coords);

this.fire('locationfound', event);
}
});

0 comments on commit 5558987

Please sign in to comment.