msteiger / jxmapviewer2

JXMapViewer2
GNU Lesser General Public License v3.0
188 stars 107 forks source link

set bounds of map by given coordinates #11

Closed greenflash1986 closed 11 years ago

greenflash1986 commented 11 years ago

can you please provide a method, which enables me to set the bounds of the map with 2 coordinates or something like that for the given frame bounds? I want to display a track on the map and would need something to display it completly on the map inside the "fixed" frame. Means: i don't want to resize the frame for settings the right bounds of the map. Thank you very much

greenflash1986 commented 11 years ago

somebody working on this? would be nice to get some feedback :( Need further information? Anything else? Best regards and thx

msteiger commented 11 years ago

Hey and sorry for the delay - I'm not 100% sure that I understood what you want, but if I did: there is not yet a method for that. Feel free to implement it and send a pull request.

What you have to do is basically this: center to the average of both geo coordinates and find the right zoom factor. The latter can be tricky as it depends on the TileFactory. For starters, you can iterate through all zoom levels and use the first(or last) one that projects both geo-coordinates into the view window. This is not great, but should work for all TileFactory implementations.

greenflash1986 commented 11 years ago

I found the method in the viewer and was able to use it. Nevertheless did I some changes in the code. I also added a trackPainter and changed the WebMapService-class. Hopefully you will accept my changes. Can you please send an Email to green.flashgmx.de that I can send you the patch? I can't use Github @work.... :(

I also would welcome the opportunity to discuss some refactoring and structure changing in this project. Maybe you can send me some chat/messenger details in your email to. Thank you.

Best regards Samuel V.