use*_*522 2 android google-maps web-services
我必须创建一个项目,其中将在Google地图上显示纬度和经度列表.这些地点将来自网络服务.我已经为当前位置,谷歌地图实施了GPS.但是如何使用标记将所有这些位置放在Google地图上.我对此并不感到困惑.我们欢迎代码和想法.
你可以用这个:
布局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>
Run Code Online (Sandbox Code Playgroud)
初始化地图:
private GoogleMap googleMap = ((MapView) rootView.findViewById(R.id.YOURMAPID)).getMap();
Run Code Online (Sandbox Code Playgroud)
设置标记:
googleMap.addMarker(new MarkerOptions().position(new LatLng( YOUR LATITUDE, -YOUR LOINGITUDE)).title("Marker"));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16232 次 |
最近记录: |