简体   繁体   English

Android GoogleMap V2如何添加具有用户屏幕尺寸的标记?

[英]Android GoogleMap V2 how to add markers with user screen size?

I am working on google map v2 and i got a question, i can now add a single marker for my current location and i know the concept about adding markers, but now i want to add more markers which near my current location, and there are thousands of markers can add into the map due to the database 我正在使用google map v2,我有一个问题,我现在可以为当前位置添加一个标记,并且我知道添加标记的概念,但是现在我想在当前位置附近添加更多标记,并且由于数据库的原因,成千上万个标记可以添加到地图中

so how can i add markers within a range of area which is surround my current location, and the range will be the user's screen size. 因此,如何在当前位置周围的区域范围内添加标记,而该范围将是用户的屏幕尺寸。 Thus more markers when zoom out and less markers when zoom in. 因此,缩小时标记更多,而放大时标记减少。

or maybe radius set as 5km of if current location 如果当前位置,则半径设置为5公里

Thanks guys 多谢你们

marker = map.addMarker(new MarkerOptions().position(
             new LatLng(location.getLatitude(), location.getLongitude()))
             .title("my position").icon(BitmapDescriptorFactory
        .defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

use this approach: 使用这种方法:

var lat=new_marker.getPosition().lat();
var lng=new_marker.getPosition().lng();

var target = new GLatLng(lat,lng);

var center= new GLatLng(yourLat, yourLng);//your gps position

var distance = center.distanceFrom(target) / 1000;//meters to km

if(distance < radius){//where radius = 5Km
    new_marker.setMap(map);//add to map
}

看起来这个示例与您正在寻找的示例相似,他想绘制一个调整为屏幕大小的圆: Google map api V2调整屏幕大小以匹配绘制的圆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM