gpt4 book ai didi

javascript - Google Maps infoWindow 显示来自 mysql 的最后数据

转载 作者:行者123 更新时间:2023-11-30 06:38:50 24 4
gpt4 key购买 nike

我知道这个问题有很多答案。我已经测试了所有,但它们不适用于我的代码。当我在我的脚本中使用代码时,它停止工作。

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);
}

最佳答案

我相信您收到此错误是因为变量 contentStringcontentString1 等在调用 createMarker 时超出范围或未定义.

确保在调用函数createMarker之前定义了这些,例如

var contentString="abc";
var contentString1="abcdef";
var contentStringPhoto="abcfegggg";

或者,将这些变量作为参数添加到您的函数中。定义:

函数 createMarker(latlng,contentString,contentString1,contentStringPhoto) {

关于javascript - Google Maps infoWindow 显示来自 mysql 的最后数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12921712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com