MApping X,y to lat/long

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

MApping X,y to lat/long

Postby pedroteixeira07 » Wed Jun 23, 2010 11:08 pm

Hi there..

I'm dealing with this issue and I cant seem to find a solution.. I have even made a drawing to explain it..
I'm trying to map the current map view to a coordinate system of Latitude/longitude, and like that I can know the visible screen which range of latitude or longitude is showing.. so I can perform a algorythm later to show some pictures and avoid them to be all in top of each one.
Image
So as you can see on the picture, I need to get this latitudes and longitudes of the current map view... depending on the screen which is showing...

I don't have much data I can use .. maybe the center of the screen coordinates which I can get it..
Any suggestions ?

Main question: Can I get thoose points of the map Latitude/longitude wise?
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Re: MApping X,y to lat/long

Postby pedroteixeira07 » Thu Jun 24, 2010 6:51 pm

Basiclly what I'm trying to do is o set an algorythm like for example in google earth.
You know if your at a certain zoom some panoramio pictures appear, if you zoom more, some others are shown, this way the cluster of pictures is avoided because some of them are filtered.

I built an algorithm in php, which just shows X number of pictures depending on the distance (lat/long) from each other... so that's why I need to use a reference like the top/bottom/left/right of the screen in latitude/longitude values to perform this algorythm... so that the pictures might have a reference values to be based on and perform the algorithm correctly

Maybe I'm on the wrong direction here.. but it was the only one I could figure out..
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: MApping X,y to lat/long

Postby pedroteixeira07 » Thu Jun 24, 2010 8:05 pm

So again here is an attempt to explain in a more clear way.. I'm trying to get the values in blue and green in the picture.. considering I just have the center position of the screen.
http://pedroteixeira.org/duvida.jpg
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: MApping X,y to lat/long

Postby bikeroute » Sat Jun 26, 2010 3:41 pm

MapView class provides getLongitudeSpan() & getLatitudeSpan(), so off the top of my head, how about something like -

Code: Select all
double longitudeDiff = (int) (getLongitudeSpan()/2);
double latitudeDiff = (int) (getLatitudeSpan()/2);

int midLat = mapView.getMapCenter().getLatitudeE6();
int midLong = mapView.getMapCenter().getLongitudeE6();

int maxLat = midLat + latitudeDiff;
int maxLong = midLong + longitudeDiff;
int minLat = midLat - latitudeDiff;
int minLong = midLong - longitudeDiff;


Edited to correct variable names.
Last edited by bikeroute on Sat Jun 26, 2010 3:57 pm, edited 1 time in total.
User avatar
bikeroute
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 26, 2010 2:51 pm
Location: UK

Re: MApping X,y to lat/long

Postby pedroteixeira07 » Sat Jun 26, 2010 3:54 pm

Hey there!

I've tried that approach also.
It was what first came to my head also but I'm getting always the value of 0 for mapView.LatitudeSpan()

PS: ( maxLong and minLong I guess is should use longitudeDiff instead of latitudeDiff)
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests