【问题标题】:Showing multiple markers in google map v2在谷歌地图 v2 中显示多个标记
【发布时间】:2014-05-01 08:16:30
【问题描述】:

我有一组经纬度坐标。我想在谷歌地图上一次显示所有这些标记。我知道如何显示单个标记。但不知道如何一次显示倍数。任何人请帮助我。

谢谢。

我有经纬度。

喜欢

id = 123 lat = 12.00 lon = 77.00

id = 124 lat = 12.01 lon = 77.01

等等

【问题讨论】:

  • 我浏览了那个博客。已经。它是在地图上添加标记。我想为我的经纬度点显示标记。

标签: android google-maps google-maps-markers google-maps-android-api-2


【解决方案1】:

希望对您有所帮助

       for(int pin=0; pin<pins.size(); pin++)
       {
             LatLng pinLocation = new LatLng(Float.parseFloat(pins.get(pin).latitude), Float.parseFloat(pins.get(pin).longitude));
             Marker storeMarker = map.addMarker(new MarkerOptions()
              .position(pinLocation)
              .title(pins.get(pin).pinname)
              .snippet(pins.get(pin).address)
           );
       }
【解决方案2】:

试试这个:

LatLng one = new LatLng(2.40744, 77.014702);//Latitude and long points
    LatLng two = new LatLng(2.407440, 77.014702);
              .......
        Similarly u can use more lat and long 

     myMarkerOne = gm.addMarker(new MarkerOptions()
    .position(one)//use LatLng obj
    .title("C") 
    .snippet("dsfd")
    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    myMarkerTwo = gm.addMarker(new MarkerOptions()
    .position(two)
    .title("C") 
    .snippet("dsfds")
    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

参考这个:How to add multiple marker and overlay in v2 google map?

也可以查看link:

【讨论】:

  • 是的,你是对的.. 但是他使用两个标记,那么我认为这不是问题。如果他去两个以上,那么他必须去循环。
【解决方案3】:

使用以下格式创建LatLng 对象:

LatLng location = new LatLng(latitude, longitude);

然后使用您的LatLng 对象和您的GoogleMap 对象调用该方法:

    private Marker setCurrentLocation(LatLng location, GoogleMap map) {
        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory
                .fromResource(R.drawable.user_location_pin);

        Marker marker = map.addMarker(new MarkerOptions().position(location)
                .icon(bitmapDescriptor).title(location.toString()));

        return marker;
    }

【讨论】:

  • 在位置我可以存储多个纬度多头位置..??怎么样?
  • 您可以创建 LatLng 对象并将它们传递给方法。
猜你喜欢
  • 2014-11-08
  • 1970-01-01
  • 1970-01-01
  • 2015-03-14
  • 2013-07-30
  • 1970-01-01
  • 1970-01-01
  • 2016-02-04
相关资源
最近更新 更多