2012-10-16 30 views
2

我知道这个问题有很多答案。我测试了所有,但他们不工作在我的代码。当我在脚本中使用代码时,它停止工作。谷歌地图infoWindow显示mysql的最后一个数据

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

这将有助于了解“停止工作”的含义。它会抛出错误还是会遇到意外的行为? – devrys

回答

0

我相信,因为变量contentStringcontentString1等超出范围或不确定时createMarker是叫你收到此错误。

确保这些调用该函数createMarker,如以前那样

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

另外,添加这些变量作为参数传递给你的FUNC定义。定义:

function createMarker(latlng,contentString,contentString1,contentStringPhoto) {