问题描述
当我分析的纬度和经度的的System.out.println(shop.getShopLat()); 的正常工作。而如果没有标记的地图工作正常。现在,我想添加使用shop.getShopLat()和shop.getShopLng()几个标记。但是,当我试图实现这个越来越redflags:构造经纬度(ArrayList中,ArrayList中)未定义有人请帮助解决这个
When I parse the lat and lng in System.out.println(shop.getShopLat()); works fine. And the Map without marker works fine. Now I want to add several marker using shop.getShopLat() and shop.getShopLng(). But when I tried to implement this getting redflags: The constructor LatLng(ArrayList, ArrayList) is undefined Someone please help to solve this?
推荐答案
请看看这一行:
for(Shop shop : this.response.shops){
map.addMarker(new MarkerOptions().position(new LatLng(shop.getShopLat(), shop.getShopLng())).title(shop.getShopAddress()));
}
在这一行要通过添加构造成一个阵列,而不是一个值来创建一个新的经纬度()对象,此行变成:
In this line you want to create a new LatLng() object by adding into constructor an array instead of one value, change this line into:
for(Shop shop : this.response.shops){
//remember to check is shop.getShopLat() is not null etc..
for(int i = 0; i < shop.getShopLat().size(); i++){
map.addMarker(new MarkerOptions().position(new LatLng( shop.getShopLat().get(i), shop.getShopLng().get(i) )).title( shop.getShopAddress().get(i) ));
}
}
这篇关于解析JSON对象(lat和液化天然气)的GoogleMap的作为标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!