想要改进这个问题吗?更新问题,以便仅通过编辑这篇文章来关注一个问题。
我必须创建一个项目,其中的纬度和经度列表将显示在谷歌地图上。这些位置将来自web服务。我已经实现了当前位置的GPS,谷歌地图。但是如何用一个标记把这些位置都放在谷歌地图上。我对此有点困惑。代码以及想法是受欢迎的。
你可以用这个:
布局 XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="250dp" >
<com.google.android.gms.maps.MapView
android:id="@+id/YOURMAPID"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</com.google.android.gms.maps.MapView>
</LinearLayout>
</ScrollView>
初始化地图:
private GoogleMap googleMap = ((MapView) rootView.findViewById(R.id.YOURMAPID)).getMap();
设置标记:
googleMap.addMarker(new MarkerOptions().position(new LatLng( YOUR LATITUDE, -YOUR LOINGITUDE)).title("Marker"));
转到此参考链接。在这个网站上,你可以回答你的问题。