【发布时间】:2014-12-13 04:54:36
【问题描述】:
我是一名新的 Android 开发人员,目前正在使用 Google Maps v2。
我只需要让用户拖动地图,但初始标记不应该随之移动。
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="20dp"
android:gravity="top|center_horizontal"
android:orientation="vertical" >
<EditText
android:id="@+id/edtDirection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_buscar"
android:lines="1"
android:maxLines="1"
android:padding="5dp" />
<Button
android:id="@+id/btnSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_buscar" />
</LinearLayout>
</RelativeLayout>
这是我的MapActivity.java,它显示了地图:
public class MapaActivity extends Activity {
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_mapa);
if (map == null) {
map = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(new LatLng(-12.0000, -77.0000)).title("Origin"));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-12.0000, -77.0000), 14));
}
}
}
有什么方法可以使用谷歌地图吗?
【问题讨论】:
标签: android google-maps google-maps-android-api-2 marker