我在谷歌地图上工作我正面临一个问题,我试图在标记上显示标题,但它没有显示。
我的代码
private void updateMarkerWithCircle(LatLng position, double radius,
float zoomLevel) {
mMap.clear();
// double radiusInMeters = radius * 100.0;
CircleOptions circleOptions = new CircleOptions().center(position)
.radius(radius).fillColor(CIRCLE_shadeColor)
.strokeColor(CIRCLE_strokeColor).strokeWidth(5);
mMap.addCircle(circleOptions);
MarkerOptions markerOptions = new MarkerOptions().position(position);
markerOptions.draggable(true);
markerOptions.title("Example");
markerOptions.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mMap.addMarker(markerOptions);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
CIRCLE_LATITUDE, CIRCLE_LONGITUDE), zoomLevel));
}
我该如何展示? 感谢
答案 0 :(得分:1)
试试这个
private void updateMarkerWithCircle(LatLng position, double radius,
float zoomLevel) {
mMap.clear();
// double radiusInMeters = radius * 100.0;
CircleOptions circleOptions = new CircleOptions().center(position)
.radius(radius).fillColor(CIRCLE_shadeColor)
.strokeColor(CIRCLE_strokeColor).strokeWidth(5);
mMap.addCircle(circleOptions);
mMap.addMarker(newMarkerOptions().position(position).title("Example").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)).draggable(true));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
CIRCLE_LATITUDE, CIRCLE_LONGITUDE), zoomLevel));
}
答案 1 :(得分:1)
I would recommend you to use the html tag in title.
function setMarker(p) {
var title = '<div><img src="icon_header_i_focus.png" onClick = "getDetails('
+ n
+ ')" /><div id ="place" style = "height:100%;width:100%" onClick = "getDetails('
+ ')"><label for="Name">'
+ PlaceName
+ '</label><br><label for="Address">'
+ PlaceAddress
+ '</label> </div><div id= "direction" ><a href="javascript:getDirections('
+ ')">directions</a>'
+ '</div></div>';
var marker = new google.maps.Marker({
icon : markerImage,
map : map,
position : pos,
animation : google.maps.Animation.DROP
});
google.maps.event.addListener(marker, 'click', function() {
if (infowindow) {
infowindow.close();
}
;
infowindow = new google.maps.InfoWindow({
content : title,
maxWidth : 300
});
infowindow.open(map, marker);
});