【发布时间】:2015-08-31 15:41:57
【问题描述】:
我正在使用 Google 地图 API V2。我已禁用 map.isMyLocationEnabled(),因此我使用自己的自定义图标代替蓝点。由于我的位置图层已禁用,因此地图不会在我的图标周围放大。有人能指点我怎么做吗?
GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange (Location location) {
LatLng loc = new LatLng (location.getLatitude(), location.getLongitude());
if (marker != null) {
marker.remove(); // remove the old marker
}
marker = map.addMarker(new MarkerOptions()
.position(loc)
.draggable(true)
.title("Not your location? wait 10 few seconds until the icon displays your real location")
.visible(true)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.mmyicon))
.flat(true)); // allows it rotate with the earth and change
// perspective as needed and retain it's
// size
map.moveCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 15));
//startIntentService(location);
}
};
map.setOnMyLocationChangeListener(myLocationChangeListener);
【问题讨论】:
-
你好@The_Martian 你能帮我评论这条评论吗?我也想在我的应用程序中使用相同的功能。 “我正在根据另一个应用程序的实时位置更新来制作汽车位置动画。那么,当我只有当前位置时,如何获取 LatLng 列表?有没有办法可以延迟应用程序的绘制以收集一些更新然后将所有内容添加到 List 对象并将其传递给您的方法并继续重复直到最终目的地?”。
-
我会说将绘图延迟几秒钟并将 LatLng 对象添加到列表中,然后循环遍历它们并将它们绘制在地图上。 Google 道路 api 有很好的文档说明如何使用我提到的相同技术消除噪音并在道路上画线。
标签: android google-maps google-maps-api-2