Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better geodesy handling #2345

Merged
merged 16 commits into from
Jan 3, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add Map distance method, close #1442
  • Loading branch information
mourner committed Jan 2, 2014
commit 5923a64ec4ef6caa3de60f53bc4a289b33fbda7c
7 changes: 7 additions & 0 deletions src/geo/crs/CRS.Simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ L.CRS.Simple = L.extend({}, L.CRS, {
return Math.pow(2, zoom);
},

distance: function (latlng1, latlng2) {
var dx = latlng2.lng - latlng1.lng,
dy = latlng2.lat - latlng1.lat;

return Math.sqrt(dx * dx + dy * dy);
},

infinite: true
});
4 changes: 4 additions & 0 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ L.Map = L.Evented.extend({
return this.options.crs.wrapLatLng(latlng);
},

distance: function (latlng1, latlng2) {
return this.options.crs.distance(L.latLng(latlng1), L.latLng(latlng2));
},

containerPointToLayerPoint: function (point) { // (Point)
return L.point(point).subtract(this._getMapPanePos());
},
Expand Down