当缩小的Android地图上消失的折线 [英] Polylines on android map disappear when zoomed out
问题描述
我用下面的code在谷歌地图(Android的API V2)5度间隔画出一堆垂直线条。直至缩小到大约缩放级别5.1,在这一点上我的所有线路全部消失的伟大工程。这是我的code错误,或者一些地图API的确故意?我怎样才能得到这些线在所有的变焦倍数显示?
非常感谢。
如果(GMAP!= NULL){
双纬度= loc_service.getLatitude();
双LNG = loc_service.getLongitude();
的LatLngBounds界限=新的LatLngBounds(新经纬度(LAT-(地图宽度/ 2),lng-(地图宽度/ 2)),新的经纬度(LAT +(地图宽度/ 2),LNG +(地图宽度/ 2)));
的CameraUpdate立方米= CameraUpdateFactory.newLatLngBounds(边界内,720,720,0);
gMap.setMyLocationEnabled(真);
gMap.moveCamera(CU); //初始化时间标志每隔一分钟
time_markers =新的ArrayList<折线>();
//计算零秒大关的距离
双偏置= getLngOffset();
的for(int i = -MARK_RNG; I< MARK_RNG;我++){
的PolylineOptions plOptions =新的PolylineOptions()
。新增(新经纬度(90,(LNG偏移+(ⅰ* 5))))
。新增(新经纬度(-90,(LNG偏移+(ⅰ* 5))))
.WIDTH(2)
。颜色(Color.BLUE); time_markers.add(gMap.addPolyline(plOptions));
}
}
这似乎是在谷歌的错误发挥着类似的我前一段时间报道之一。
我只是想
map.addPolyline(新的PolylineOptions()
。新增(新经纬度(90,5))
。新增(新经纬度(-90,5))
.WIDTH(2)
。颜色(Color.BLUE));
和它绘制一条线从 0,0
到 0.5
低缩放级别,并从 0.5
到 90,5
您放大后,两者当然是不正确。
一个解决方法是使用 85
而不是
map.addPolyline(新的PolylineOptions()
。新增(新经纬度(85,5))
。新增(新经纬度(-85,5))
.WIDTH(2)
。颜色(Color.BLUE));
但不要问我为什么它工作正常这样...
您可能还需要更多信息添加到链接的问题报告。
I am using the code below to draw a bunch of vertical lines at 5 degree intervals on a Google map (android API v2). All works great until zooming out to approximately zoom level 5.1, at which point all my lines disappear. Is this a bug in my code, or something that the maps API does on purpose? How can I get these lines to show up at all zoom scales?
Thanks very much.
if (gMap != null) {
double lat = loc_service.getLatitude();
double lng = loc_service.getLongitude();
LatLngBounds bounds = new LatLngBounds(new LatLng(lat-(MAP_WIDTH/2), lng-(MAP_WIDTH/2)), new LatLng(lat+(MAP_WIDTH/2), lng+(MAP_WIDTH/2)));
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 720, 720, 0);
gMap.setMyLocationEnabled(true);
gMap.moveCamera(cu);
// initialize the time marker AT ONE MINUTE INTERVALS
time_markers = new ArrayList<Polyline>();
// calculate distance to zero-second mark
double offset = getLngOffset();
for (int i=-MARK_RNG; i<MARK_RNG; i++) {
PolylineOptions plOptions = new PolylineOptions()
.add(new LatLng(90, (lng-offset + (i*5))))
.add(new LatLng(-90, (lng-offset + (i*5))))
.width(2)
.color(Color.BLUE);
time_markers.add(gMap.addPolyline(plOptions));
}
}
This seems like a bug in the Google Play Services library similar to the one I reported some time ago.
I just tried
map.addPolyline(new PolylineOptions()
.add(new LatLng(90, 5))
.add(new LatLng(-90, 5))
.width(2)
.color(Color.BLUE));
and it draws a line from 0,0
to 0,5
on low zoom levels and from 0,5
to 90,5
after you zoom in. Both are of course incorrect.
A workaround would be to use 85
instead
map.addPolyline(new PolylineOptions()
.add(new LatLng(85, 5))
.add(new LatLng(-85, 5))
.width(2)
.color(Color.BLUE));
but don't ask me why it works correctly this way...
You may also want to add more info to the linked issue report.
这篇关于当缩小的Android地图上消失的折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!