我使用过Google Map Api。 当我开发仪表板时,Map和Info窗口工作正常。 但有时在Info窗口停止正常显示之前。 我更新了Api版本仍然无法正常工作。 我在两个项目中使用了这个Map Api,两个地方的行为都相同。 仅显示关闭图标和箭头图标,但内容不可见。 Screen shot of the map
这是在Map上设置标记的功能。
function showOnMap(_data,_objFlag){
var markers = [];
if(_objFlag=='disease'){
for(i=0;i<_data.length;i++)
{
var markerUrl = "";
if(_data[i].disease.length>1){
markerUrl = baseUrl+"images/marker_add.png";
}else{
markerUrl = baseUrl+"images/location-pin-"+_data[i].disease[0].color+".png";
}
var MapMarker = {
id:i
,disease:_data[i].disease
,address:_data[i].address
,latitude: _data[i].lat
,longitude: _data[i].lng
,imgUrl: markerUrl
};
markers.push(MapMarker);
}
var map = mapWidget.getMap();
markerCluster.init(map);
markerCluster.setClusterClickListner(onClusterClicked);
markerCluster.setMarkerClickListner(onMarkerClicked);
markerCluster.setClusterMouseOverListner(onClusterMouseOver);
markerCluster.setClusterMouseOutListner(onClusterMouseOut);
markerCluster.addMultipleMarkers(map,markers,_objFlag);
}
}
这是点击标记时的功能:
function onMarkerClicked(e){
//console.log(e);
var content = getMarkerInfo(e);
//var content = "<div style='width:300px;background:#f00;height:100px;'>Hello World</div>";
var info = new google.maps.MVCObject;
info.set('position', e.center_);
console.log(content)
if(content!=""){
markerCluster.displayMarkerCallout(e, content);
}
}
这是获取标记信息的功能:
function getMarkerInfo(_marker){
//console.log(_marker);
var content = "";
content = "<div style='width:150px;'>";
for(var i=0; i<_marker.disease.length; i++){
var imgPath = baseUrl+"images/graph/"+_marker.disease[i].color+".jpg";
if(_marker.disease[i].name.length>10){
var disName = _marker.disease[i].name;
var wrapDisName = disName.substring(0, 10)+"..";
}else{
var disName = _marker.disease[i].name;
var wrapDisName = disName;
}
var count = _marker.disease[0].count;
content = content + "<div style='font-size:12px;width:100%; word-wrap: break-word;'><img src='"+imgPath+"' style='width:9px;height:9px;'> <span><strong><span style='position: relative;' title='"+_marker.disease[i].name+"'>"+wrapDisName+"</span></strong></span>"+
" <span style='font-size:11px;color:#8C8888;position: relative;'>("+count+")</span></div>"
}
if(_marker.address == null || _marker.address ==""){
address = "Unknown";
}else{
address = _marker.address;
}
content = content + "<div style='border-top:1px solid #cccccc;margin-top:6px;padding-top:2px;width:100%; word-wrap: break-word; font-size:11px'>"+address+"</div></div>"
return content;
}