我正在使用谷歌地图显示公交车的位置,我已经创建了自定义信息窗口来替换谷歌地图中的标记,但我得到它高于默认值,我怎么能禁用默认值?是否可以随时显示所有标记的信息窗口而无需触摸它们?
我感谢任何帮助。
强文
private boolean initMap() {
if (map == null) {
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = mapFrag.getMap();
// This part here to set the custom Info Window.
if (map != null) {
map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(
R.layout.info_window, null);
TextView tv_route_direct = (TextView) v
.findViewById(R.id.route_direct);
tv_route_direct.setText(marker.getTitle());
return v;
}
});
}
}
return (map != null);
}
private void gotoLocation(int id, double lat, double lng,
String route_direct) {
final float zoom = 11;
LatLng ll = null;
if (markerMap.containsKey(id)) {
// Update the location.
// To figure out which ones was not updated.
idList.add(id);
marker = markerMap.get(id);
// Remove from the map fragment.
marker.remove();
// Remove from the HashMap tp add the new one.
markerMap.remove(id);
ll = new LatLng(lat, lng);
if (lat != 0 && lng != 0 && !route_direct.isEmpty()) {
MarkerOptions markerOpt = new MarkerOptions()
.title(route_direct).position(ll).visible(true);
marker = map.addMarker(markerOpt);
markerMap.put(id, marker);
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll,
zoom);
map.moveCamera(update);
map.animateCamera(CameraUpdateFactory.zoomIn());
map.animateCamera(CameraUpdateFactory.zoomTo(11), 2000, null);
System.out.println("test end of the update part.");
}
}
答案 0 :(得分:0)
试试这个:
marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.UrMarkerIcon));