How to use Projection object

11 views
Skip to first unread message

DWoods

unread,
Feb 12, 2018, 5:32:23 PM2/12/18
to Leaflet
According the manual, Projection is "An object with methods for projecting geographical coordinates of the world onto a flat surface (and back)".
It has out-of-box projection defined such as "L.Projection.LonLat" and "L.Projection.Mercator".
It also has methods such as project(<LatLng>latlng) that returns a Point.

My question is how do I get a reference to the object so that I can call its 'project' method.

I have a LatLng var 'latLng', and I tried the following to project it , none of them worked:

- L.Projection.project(latLng);        [Error message: L.Projection.project is not a function]

- L.Projection.LonLat.project(latLng)              [Error message: TypeError: Cannot read property 'project' of undefined]

- Projection.project(latLng)           [Error message: Projection not defined]

Thanks in advance.
DW






DWoods

unread,
Feb 12, 2018, 5:49:33 PM2/12/18
to Leaflet
Instead of trying to get a hold of this so called Projection object, I tried to use project/unproject methods of Map, which worked. But the Projection object remains a mystery to me. 
Reply all
Reply to author
Forward
0 new messages