Leaflet.js with a non real world map! Coordinates

2019-05-24 12:26发布

I'm working on creating a map of Day Z (the game) with leaflet JS and want to be able to plot items on the map using the in game coordinate system see http://dayz.ollieb.net

In game the top left coordinate is 000 000, then 001, 001 where units of 10 represent a grid so 010, 010 would be the top left "grid" (similar to ordinance survey).

How do I create a method to convert the provided coordinate systems (either points or latlong) to work on this way. Basically they just need to go from 000, 000 (top left) to 145, 130 (bottom right). Currently I am having trouble using lat/long as it curves to compensate for the projection and points (x/y) seem to change per computer!

How can I take an in game point and create a marker on the map at that point? Presumably I need to tell Leaflet.js what "number" the top left and bottom right of the map are somehow?

Sorry for the lack of understanding, I have read through all the docs and can't see anything like this mentioned!

See an example here: http://dabrothas.net/sei/daisy/index.asp?mode=mark&z=3&x=-109.2294921875&y=73.49222029152183

3条回答
一夜七次
2楼-- · 2019-05-24 12:53

I'm Leaflet author.

Check out the following issues for code examples on setting up a non-world CRS: https://github.com/Leaflet/Leaflet/issues/210 https://github.com/Leaflet/Leaflet/pull/676

I plan to do some refactoring of projection logic for 0.4 release to make such things much easier and more natural, so stay tuned!

查看更多
迷人小祖宗
3楼-- · 2019-05-24 12:54

Leaflet 0.8-dev has advanced enough to permit completely custom coordinate systems, here is a example that works perfectly on the meter scale, with linear CRC, even with a scale widget:

https://gist.github.com/MarZab/7e3b1522ebc383f448a0

查看更多
三岁会撩人
4楼-- · 2019-05-24 13:02

A grid coordinate system could be made to bear close resemblance to a sector on a sphere with nearly square properties if it is made to occur just beneath the equator at zero degrees longitude. For all intents, over a 15 mile distance, the longitudinal lines will be very nearly parallel.

From here it would be a matter of scaling the grid coordinates to some $t$ seconds in width and height, and then set up a normalizing method that can feed Leaflet LatLng coordinates that it appears to need. Since you're staying in one hemisphere, with 0 degrees latitude/longitude at the northwest, your latitude will always be negative. Hope this gets you thinking...

查看更多
登录 后发表回答