We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I've been using Unfolding Maps and found it very useful. I was wondering if it was possible to map lat/long coordinates directly from a MySQL database. On the Unfolding maps site, there seems to be no tutorial regarding this, though it says it's possible. I've used the Beziersqlib to connect to the database. Does anyone know how to query and map points directly from the DB?
Answers
Hi,
in principle you have to connect to the database, query your lat/long coordinates, and map them to screen coordinates. You can either do that manually (via
map.getScreenPosition(location)
), or by creating Markers.Here is some untested code (sitting in a train right now). You need to use your actual database credentials, of course.
Thanks for the advice! It's working
I've stored the coordinates in 2 arraylists (2 map areas), and I've managed to display them onscreen. I have 2 side-by-side maps. The problem is that points from one map are displayed outside of the map area, overlapping onto the other map. Is there a way I can restrict points to within a map area, perhaps by limiting draw() in a specific area?
Check the coordinate values against the bounds of the map. (Using < and >, of course.)
It took me a while, but I worked it out. Thanks for the help!
Here's the code (may be useful for someone else):
For future reference: If you are using Unfolding's Marker they would appear only on the map itself (as it cuts them off at the border). No need for checks, then.
(related question posted as new discussion)