Issue
I'm developing an application with the MapView and the GPS. My problem is that the user might disconnect while using my application, so he'll be walking in a fully grey map. I'd like to cache the map temporarily in order to see it later. I know that cache the map isn't allowed by the google maps API, but I want to be sure if TEMPORARILY cache it (and delete it when the app is closed) is also forbidden.
I've heard about openstreetmaps / osmdroid, but I'd like to confirm that I HAVE to use it before deleting half of my code.
Solution
Because I need the satelliteView, I finally used a method that could be improved.
I start a thread that asks the controler to go to a location near the user. It's downloaded and the cache is managed by the MapView:
int latitudeSpan = mapView.getLatitudeSpan();
int longitudeSpan = mapView.getLongitudeSpan();
for(int i=-MEMORIZED_MAP_SIZE;i<=MEMORIZED_MAP_SIZE;i++)
{
for(int j=-MEMORIZED_MAP_SIZE;j<=MEMORIZED_MAP_SIZE;j++)
{
synchronized (this)
{
if(i==j&&j==0) j++;
Message msg = new Message();
msg.arg1=latitude+latitudeSpan*i;
msg.arg2=longitude+longitudeSpan*j;
msg.setTarget(MainActivity.handler);
msg.sendToTarget();
try
{
wait(5000);
}
catch(Exception e){}
}
}
}
Now, I just need to find another way than "wait(5000)" to know that the part of the map I'm looking at is downloaded. I'll modify this message if I find one.
Answered By - Setsuki
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.