【发布时间】:2014-10-16 11:41:28
【问题描述】:
我正在使用适用于 Android 的 Google Maps API v2,我想在地图上放置几个标记。我有如下代码
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
MapFragment fm = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
map = fm.getMap();
rootView.findViewById(R.id.map_hybrid).setSelected(true);
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
map.getUiSettings().setCompassEnabled(true);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(39.15326,-9.362926))
.zoom(15)
.build();
MapFragment.newInstance(new GoogleMapOptions()
.camera(cameraPosition));
map.addMarker(new MarkerOptions().position(new LatLng(39.15326,-9.362926))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.btn_map_home)));
while(i < mapInfo.size())
{
BitmapDescriptor mapIcon;
... changes the resource of the mapIcon accordingly...
map.addMarker(new MarkerOptions()
.draggable(false)
.title(((ArrayList<String>) mapInfo.get(i)).get(3))
.position(new LatLng(((ArrayList<Double>) mapInfo.get(i)).get(0), ((ArrayList<Double>) mapInfo.get(i)).get(1)))
.icon(mapIcon));
i = i + 1;
}
每当我放大和缩小时,图标都会移动。我希望他们被修复
编辑: 解释问题的图像。
【问题讨论】:
-
你能解释一下你所说的“静态”是什么意思吗?您不希望引脚处于某个坐标吗?它会随着您放大或缩小而移动,因为视图中的坐标正在发生变化
-
我更新了,我想修复它。不要通过放大或缩小来改变位置。我在哪里可以改变它?
-
将它们叠加在地图上,而不是将它们添加到地图中
-
不是在 api v2 上停止了吗?
-
我尝试作为 GroundOverlay 进行操作,但没有成功
标签: android google-maps google-maps-markers google-maps-android-api-2