commenthol / leaflet-rastercoords

Leaflet plugin for plain image map projection to display large images using tiles generated with gdal2tiles-leaflet
https://commenthol.github.io/leaflet-rastercoords
MIT License
122 stars 23 forks source link

How to customize the image start point on the map #4

Closed mottab closed 6 years ago

mottab commented 6 years ago

Hi,

Thank you very much, this is a helpful library to make really cool apps.

I need to change the starting point of the image so that when I call project or unproject, it just converts the values regarding a specific location on the map.

for example:

Now when I unproject a point point [0, 0] I got the following point LatLng {lat: 85.0511287798066, lng: -180} how can I customize this starting point let's say to [55, 25]

Thanks in advance

commenthol commented 6 years ago
const changeOrigin = (coords) => [coords[0] - 55, coords[1] - 25]
rc.unproject(changeOrigin(coords))
mottab commented 6 years ago

@commenthol Thanks, it seems simple but I am still can't get it. Let me explain more, I have an array of markers' locations and I also have an image that will appear using your library. This image shows another place of the world.

For example: The image location is between latlng(a, b), and latlng(c, d). and I have an array of locations for markers to put them on the image. The problem happens when I try to translate these locations to appear in the image.

Should I make this using the changeOrigin method you passed? If yes, unproject is used only for points, and I have locations, should I call project first and then unproject using the changeOrigin function?

Thanks

mottab commented 6 years ago

In other words, can I fit the raster-image to a specific place in the world?

commenthol commented 6 years ago

This project maps flat images to its own flat world. The pixel coordinates used with project() and unproject() have no relation to WGS84 coordinates.