Android 在Google map V2上添加多个标记

Android 在Google map V2上添加多个标记,android,google-maps,google-maps-markers,Android,Google Maps,Google Maps Markers,嗨,我正在开发一个小的android应用程序,我想在其中显示地图和地图上的一些标记。我有latlang值的列表,我想在地图上显示它。我尝试了以下方法: for(int pin=0; pin<pins.size(); pin++) { LatLng pinLocation = new LatLng(Float.parseFloat(pins.get(pin).latitude), Float.parseFloat(pins.get(pi

嗨,我正在开发一个小的android应用程序,我想在其中显示地图和地图上的一些标记。我有latlang值的列表,我想在地图上显示它。我尝试了以下方法:

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)
                );
            }
for(int-pin=0;pin
for(int-pin=0;pin)在这里我做了一些更改,添加了“pinLocation”而不是“storeLocation”
.title(pins.get(pin.pinname)
.snippet(pins.get(pin.address)
);
}
>首先检查销的尺寸。尺寸()。。
for(int pin=0;pin在这里我做了一些更改,添加了“pinLocation”而不是“storeLocation”
.title(pins.get(pin.pinname)
.snippet(pins.get(pin.address)
);
}
>首先检查销的尺寸。尺寸()。。

使用如下共享首选项

  // Opening the sharedPreferences object
        sharedPreferences = getSharedPreferences("location", 0);

        // Getting number of locations already stored
        locationCount = sharedPreferences.getInt("locationCount", 0);

        // Getting stored zoom level if exists else return 0
        String zoom = sharedPreferences.getString("zoom", "0");

        // If locations are already saved
        if(locationCount!=0){

            String lat = "";
            String lng = "";

            // Iterating through all the locations stored
            for(int i=0;i<locationCount;i++){

                // Getting the latitude of the i-th location
                lat = sharedPreferences.getString("lat"+i,"0");

                // Getting the longitude of the i-th location
                lng = sharedPreferences.getString("lng"+i,"0");

                // Drawing marker on the map
                drawMarker(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)));
            }

使用如下共享首选项

  // Opening the sharedPreferences object
        sharedPreferences = getSharedPreferences("location", 0);

        // Getting number of locations already stored
        locationCount = sharedPreferences.getInt("locationCount", 0);

        // Getting stored zoom level if exists else return 0
        String zoom = sharedPreferences.getString("zoom", "0");

        // If locations are already saved
        if(locationCount!=0){

            String lat = "";
            String lng = "";

            // Iterating through all the locations stored
            for(int i=0;i<locationCount;i++){

                // Getting the latitude of the i-th location
                lat = sharedPreferences.getString("lat"+i,"0");

                // Getting the longitude of the i-th location
                lng = sharedPreferences.getString("lng"+i,"0");

                // Drawing marker on the map
                drawMarker(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)));
            }

for(int i=0;i
for(int i=0;i
您可以这样使用:

for (int i = 0; i < pins.size(); i++) {

 double lati=Double.parseDouble(pins.get(i).latitude);
 double longLat=Double.parseDouble(pins.get(i).longitude);
 MAP.addMarker(new MarkerOptions().
 position(
 new LatLng(lati,longLat)).title(pins.get(i).pinname).snippet(pins.get(i).address));


 }
for(int i=0;i
您可以这样使用:

for (int i = 0; i < pins.size(); i++) {

 double lati=Double.parseDouble(pins.get(i).latitude);
 double longLat=Double.parseDouble(pins.get(i).longitude);
 MAP.addMarker(new MarkerOptions().
 position(
 new LatLng(lati,longLat)).title(pins.get(i).pinname).snippet(pins.get(i).address));


 }
for(int i=0;i
参考这一个可能有用…请跟随链接参考这一个可能有用…请跟随链接Altaf我尝试了你的解决方案,但仍然不起作用。是否有其他方法检查你的数组大小?是的,先生,数组大小为2。仍然我不知道它只显示了最后一个标记。@nilkash我有完全相同的pr问题。你能解决吗?Altaf我试过你的解决方案,但仍然不起作用。你有没有其他方法检查你的数组大小?是的,先生,数组的大小是2。但我不知道它只显示了最后一个标记。@nilkash我有完全相同的问题。你能解决吗?
for (int i = 0; i < pins.size(); i++) {

 double lati=Double.parseDouble(pins.get(i).latitude);
 double longLat=Double.parseDouble(pins.get(i).longitude);
 MAP.addMarker(new MarkerOptions().
 position(
 new LatLng(lati,longLat)).title(pins.get(i).pinname).snippet(pins.get(i).address));


 }