2

我正在使用谷歌地图 v2 api。在那我需要显示多个标记和多个叠加层。我对此一无所知。如果有人知道答案,请分享您的想法。谢谢你。

对于单个标记和覆盖,我使用此代码

 hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
          .title("Hamburg")
     .snippet("Kiel is cool")
   .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
4

2 回答 2

2

像这样使用

            LatLng one = new LatLng(2.40744, 77.014702);//Latitude and long points
        LatLng two = new LatLng(2.407440, 77.014702);
        LatLng three = new LatLng(2.4013, 76.951340000000002);
            .......
            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)));

        myMarkerThree = gm.addMarker(new MarkerOptions()
        .position(three)
        .title("A") 
        .snippet("dfd")
        .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

等等..

于 2013-06-19T06:17:57.420 回答
1
Try this one.It will be better



String values[]={"2.40744, 77.014702","6.407440, 77.014702","10.4013, 76.951340000000002"};

    GoogleMap googleMap;

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);


            SupportMapFragment supportMapFragment = (SupportMapFragment)
                    getSupportFragmentManager().findFragmentById(R.id.map);



            // Getting a reference to the map
            googleMap = supportMapFragment.getMap();


             for(int i=0;i<values.length;i++)
        {

            String s[] = values[i].split(",");

            String v1 = s[0];
            String v2 = s[1];
        googleMap.addMarker(new MarkerOptions()
        .position(
                new LatLng(Double.valueOf(v1),Double.valueOf(v2)))
        .title("Hi")
        .icon(BitmapDescriptorFactory
                .fromResource(R.drawable.ic_launcher)));


        }
    }
于 2013-07-30T07:30:23.783 回答