Android Map Overlay Disappears on Zoom

雨燕双飞 提交于 2019-12-04 04:11:39

问题


I'm having a headache with Android's Google Maps API... I draw some overlays on the map and it's all fine, it updates regularly and handles gestures well, no problem... However, when I zoom in to perhaps level 15-16 or beyond, one or more of the larger polygons aren't redrawn. This only occurs in cases where the centroid of a circle for example lies beyond the bounds of the screen, and only occurs when zooming in.. it does not occur when zooming out, nor does it occur if one pans the map in any direction (translation).

When zooming in very close, I'm guessing the system disregards the overlay/shape, treating it as unimportant? I want any shape intersecting with the screen's bounds to be drawn. Am I missing something obvious here, because I can't seem to find any definitive answer on how to treat this scenario.


回答1:


I'd a similar problem, but I was using only squares, which make it easier to solve.

Problem details (at lest with squares):

canvas.drawRect() only draws the rectangle if both top and bottom of rectangle have coordinates within visible screen. As soon as the top or the bottom of the rectangle have a coordinate outside screen, it's not drawn.

Solution I've used for squares

I croped the square to make it always fit within the visible screen coordinates, and it was correctly drawn.

If you are using more complex figures, this solution may be more dificult to implement.

good luck.




回答2:


The way I implemented it was using the mapviewballons as library here then using the call to
super(boundCenter(defaultMarker), mapView);

The boundCenter keeps the centroid on the screen whose overlay is on screen and on zooming it is unaffected.



来源:https://stackoverflow.com/questions/12713671/android-map-overlay-disappears-on-zoom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!