So what i'm trying to do is a web-application to calculate routes between two coordinates. I've set up a map with leafletjs with the first tile server in the list on this page. I set up a function which returns the coordinates where I click on the map. The thing, that is irritating to me, is that the coordinates that my map returns are not the same as other web-maps return (for example openrouteservice-map) for the exact same position. Here's an example: These are the coordinates from my map: 85327.45845973487,46.94840207976996 (long, lat). These are the coordinates from the openrouteservice-map: 7.457968, 46.948518 (long, lat) for the exact same position. The longitude value is very different between the two. So my question is, why are the coordinates that my map returns, different than what other maps return? And also, if I use the coordinates of my map for the route calculation, they don't work. I have aready tried changing the CRS (Coordinate Reference System), but that didn't do a difference. Any help or hint is very appreciated, thank you. asked 29 Nov '21, 10:47 nicolabaechi |
I managed to solve my issue by setting a boundingbox as @Spiekerooger suggested, thank you :). I did that like this:
answered 30 Nov '21, 10:27 nicolabaechi |
Add a link to your (dev) site where we can check what you are doing. Sth. is either wrong here: "I set up a function which returns the coordinates where I click on the map" or you just scrolled "endlessly" to the right before clicking on the map and by that got that crazy long coordinate. You may also set a bounding box for your map in leaflet to disable the option of endless scrolling in any direction, so your long will be between -180 and 180 (and lat between -90 and 90).
Hey, I set up this codesandbox. Don't know if it works in the environment, maybe pull it locally. Yes what you said could be, but what would cause this behaviour?