Android google maps tile overlay update on zoom - android

I have a tile overlay in Android Google Map. Everything works fine. But when I zoom in, all tiles disappear then new tiles are downloaded and only after 1-2 secs(when new tiles are downloaded) the map shows them. Therefore, the map doesn't show tiles for some time. Is there a way to update tiles only when new tiles are downloaded?
I use a basic UrlTileProvider and Aeris Overlay maps.

Anyway, you can download each tile as image to local internal or external storage with, for example, Picasso library (or separate Thread or AsyncTask) and determine "all new tiles are downloaded" event "manually" (e.g. increment downloaded tiles counter on every public void onSuccess() for Picasso or protected void onPostExecute() for AsyncTask or on end of public void run() for Thread and wait that equals all tiles quantity) then use TileProvider for downloaded tiles local storage like in this answer of Alex Vasilkov.
Update
For showing previous map when tiles for zoom+1 level still downloading it's possible to create GroundOverlay with screenshot of current map view. Screenshot of google map you can do like in answers for this question of DiscDev
Update #2
There are several ways to solve you problem: 1) you can create custom view which extends MapView class like in this answer and show in overridendispatchDraw() method whatever you want or 2) you can set ImageView over your MapView and show it with screenshot on it while zoom changed and new tiles loaded. And if necessary you can translate tap events from ImageView to MapView and so on.
I prefer p.1 - create MapView-based custom view, override dispatchDraw() and show temporary map within it while new map loading.

Related

Keep custom Google Map overlay tiles visible after zoom

I'm using Tile Overlay feature of Google Map for Android to display custom map tiles, provided by third party service.
My problem is that, when user zooms the map, and it switches to next zoom level, already visible tiles are disappearing, and then getTile() method of my TileProvider implemetation is triggered. This causes unpleasant blinking of my map view, and moments when user can see only default map.
Standard Google Map behavior scales and "overzooms" currently visible tiles, until new ones are loaded. Is there any way I can create the same effect with Tile Overlay? I am aware that "overzoomed" tiles can be blurry, but that is ok in my case.
Remove custom tiles when zoom level changed is default Android GoogleMap behavior. To "suppress" it (showing previous map when tiles for zoom±1 level still downloading ) you can:
1) create GroundOverlay with screenshot of current map view. Screenshot of google map you can do like in answers for this question of DiscDev and remove it when tiles downloaded;
2) create custom view which extends MapView class like in this answer and show in overridden dispatchDraw() method whatever you want;
3) you can set ImageView over your MapView and show it with screenshot on it while zoom changed and new tiles loaded. And if necessary you can translate tap events from ImageView to MapView and so on.
I prefer p.2 - create MapView-based custom view, override dispatchDraw() and show temporary map within it while new map loading.

Loading osmdroid MapView in a new thread

Loading of the map in my application was slow on some devices. I wanted to load the map in a different thread and show a progress dialog until it is done.
I found this article: http://pygmalion.nitri.de/android-starting-an-activity-containing-a-mapview-takes-forever-380.html
I think that the only thing it does is waiting for defined time and then run the code inside the run() method. That's not what I want.
I tried to use ASyncTask with the same XML layout as in the article above:
in doInBackground()
created MapView by new MapView(MyActivity.this);
setters for multitouch, zoom controls, tilesource (offline with osmbonusback)
in onPostExecute()
added mapview to the prepared FrameLayout
The map loaded correctly but the zoom coontrols were on the top of the screen. Also when I zoomed in, the tiles got rescaled instead of loading the correct zoom level tiles - until I moved the map.
Is there any way to open the activity instantly, wait for the map and let the user know it is loading?

Displaying the same tiles when zoomed in instead of getting them from server

I want to display tiles on a map but when I zoom in too much the tiles disappear because the server doesn't have those tiles. I want to display the previously loaded tiles even if the user zooms in a lot.
Following is the code
url_tile_provider = new UrlTileProvider(
PathFinder.rainradar_HDBaseurl, uidList.get(0), db, TAG);
tileoverlay_default = googleMap
.addTileOverlay(new TileOverlayOptions().tileProvider(
url_tile_provider).visible(true));
If you are zooming too much than existing tiles get blur so it will try to get high resolution image. you can not restrict default map v2 but if you are using map like osmand that you have to change tiles loading logic and yo can restrict loading new tiles

Android Map has loaded fully

I have a requirement where in i need to take an image of mapview and use it for displaying in a pdf. I am able to take the image and display it in pdf but the only issue is when i am taking the snap of the MapView sometimes the map is not fully loded.
Is there any event which can notify me if the map is fully loaded or any other way to know if the map is loaded in android app.
So after too many days of findings what i end up with is that there is no 100 % guranteed way of finding it. There are few methods present thought one of them being:
canCoverCenter
public boolean canCoverCenter()
Checks whether we currently have a map tile to cover the center of the map.
Returns:
True if there is a tile for the center, false otherwise.
But it only notifies for the center tile and not all the tiles. :(

android google map changeing on the run

i have a map view using google map API
in my map i have few overlays markers which i've designed throw extending the ItemizedOverlay.
i want to change this markers drawable image after the map is already visible to user.
is it possible ?
my intention is to run some lazy drawable loading (like you do in a list view), because all my images are coming from the web, and i don't want the user to wait for all the images to load before i load the map.
on a list view its kind of easy, because the thread will update the ImageView, but here i don't know how to access a specific item after the map has loaded..
thanks!
Check out the function setMarker in OverlayItem. It will let you change the image for a specific marker. Just make sure you centerBound the image before setting it.
OverLayItem
According to me first load all the dummy iamges and show it on the mapview and simultaniously start a background task to download all the images from server and once the image downloads process completes just clear all the overlays on the mapview and reload the actually downloaded images on the mapview.

Categories

Resources