我知道这个问题有很多答案。我已经测试了所有,但它们不能用于我的代码。当我在脚本中使用代码时,它停止了工作。
function createMarker(latlng) {
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon:'images/intake.png',
html:(contentString,contentString1,contentStringPhoto)
});
infoBubble = new InfoBubble({
maxWidth: 400
});
var div = document.createElement('DIV');
div.innerHTML = 'NN-Gis';
infoBubble.addTab('Information', contentString);
infoBubble.addTab('Information', contentString1);
infoBubble.addTab('Photo', contentStringPhoto);
google.maps.event.addListener(marker, 'click', function() {
if (!infoBubble.isOpen()) {
infoBubble.setContent(contentString,contentString1,contentStringPhoto);
infoBubble.open(map,marker);
}
});
}
google.maps.event.addDomListener(window, 'load', init);
function updateStyles() {
var shadowStyle = document.getElementById('shadowstyle').value;
infoBubble.setShadowStyle(shadowStyle);
var padding = document.getElementById('padding').value;
infoBubble.setPadding(padding);
var borderRadius = document.getElementById('borderRadius').value;
infoBubble.setBorderRadius(borderRadius);
var borderWidth = document.getElementById('borderWidth').value;
infoBubble.setBorderWidth(borderWidth);
var borderColor = document.getElementById('borderColor').value;
infoBubble.setBorderColor(borderColor);
var backgroundColor = document.getElementById('backgroundColor').value;
infoBubble.setBackgroundColor(backgroundColor);
var maxWidth = document.getElementById('maxWidth').value;
infoBubble.setMaxWidth(maxWidth);
var maxHeight = document.getElementById('maxHeight').value;
infoBubble.setMaxHeight(maxHeight);
var minWidth = document.getElementById('minWidth').value;
infoBubble.setMinWidth(minWidth);
var minHeight = document.getElementById('minHeight').value;
infoBubble.setMinHeight(minHeight);
var arrowSize = document.getElementById('arrowSize').value;
infoBubble.setArrowSize(arrowSize);
var arrowPosition = document.getElementById('arrowPosition').value;
infoBubble.setArrowPosition(arrowPosition);
var arrowStyle = document.getElementById('arrowStyle').value;
infoBubble.setArrowStyle(arrowStyle);
}
答案 0 :(得分:0)
我认为您收到此错误是因为变量contentString
,contentString1
等在调用createMarker
时超出范围或未定义。
确保在调用函数createMarker
之前定义了这些内容,例如
var contentString="abc";
var contentString1="abcdef";
var contentStringPhoto="abcfegggg";
或者,将这些变量作为参数添加到您的func中。定义:
function createMarker(latlng,contentString,contentString1,contentStringPhoto) {