【发布时间】:2013-01-17 09:56:35
【问题描述】:
我在网上进行了很多搜索,但没有找到任何可以回答我的问题的内容。 当我使用
启用 MyLocationgmap.setMyLocationEnabled(true)
我会自动获得一个按钮,让地图以我当前的位置为中心。 我想删除它,所以我问你怎么做。 我希望你们中的某个人可以帮助我!
【问题讨论】:
标签: android google-maps
我在网上进行了很多搜索,但没有找到任何可以回答我的问题的内容。 当我使用
启用 MyLocationgmap.setMyLocationEnabled(true)
我会自动获得一个按钮,让地图以我当前的位置为中心。 我想删除它,所以我问你怎么做。 我希望你们中的某个人可以帮助我!
【问题讨论】:
标签: android google-maps
在您的GoogleMap 对象上调用以下方法后:
map.setMyLocationEnabled(true);
map.getUiSettings().setMyLocationButtonEnabled(false);
您应该会看到当前位置指示器(蓝色圆圈),但无法控制以该位置为中心的地图。
【讨论】:
答案很简单;
gmap.setMyLocationEnabled(true); ==> means "to center the map on my current location"
gmap.setMyLocationEnabled(false); ==> means "NOT to center the map on my current location"
[更新]
如果您想删除地图上的位置按钮,请在下面的代码中搜索并删除它;
public void setMyLocationButtonEnabled(View v) {
if (!checkReady()) {
return;
}
// Enables/disables the my location button (this DOES NOT enable/disable the my location
// dot/chevron on the map). The my location button will never appear if the my location
// layer is not enabled.
mUiSettings.setMyLocationButtonEnabled(((CheckBox) v).isChecked());
}
public void setMyLocationLayerEnabled(View v) {
if (!checkReady()) {
return;
}
// Enables/disables the my location layer (i.e., the dot/chevron on the map). If enabled, it
// will also cause the my location button to show (if it is enabled); if disabled, the my
// location button will never show.
mMap.setMyLocationEnabled(((CheckBox) v).isChecked());
}
【讨论】:
你尝试过这样的事情吗?
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/backgroundMap"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:uiZoomControls="false"
map:uiCompass="false"
class="com.google.android.gms.maps.SupportMapFragment"/>
它有效地从我的地图上删除了所有默认 UI,除了与标记相关的 UI。 查看this链接了解更多信息。
编辑
回复 OP 的评论,id 建议使用自定义位置算法,而不是让谷歌地图 API 接管。我以前做过,而且不是很痛苦,我只是在地图上放了一个标记让用户知道他在哪里,并使标记可拖动,以便用户可以手动调整他的位置。
检查this 链接。
【讨论】: