2017-06-19 94 views
0

我需要的所有信息窗口的開放,我希望答案是C#,但我想這從多個標記打開的所有信息窗口,谷歌地圖

function myMap() { 
var mapProp= { 
center:new google.maps.LatLng(36.109667, 43.3575), 
zoom:9, 
}; 

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp); 


var locations={[36.3518, 43.3793], 
    [35.7981, 43.2932], 
    [36.1791, 43.4000], 
    [36.3518, 43.3793], 
    [35.7981, 43.2932], 
    [36.1791, 43.4000], 
    [36.3518, 43.3793], 
    [35.7981, 43.2932], 
    [36.1791, 43.4000]} 
for (var i = 0; i < locations.length; i++) { 
var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
    map: map 
}); 

var infowindow = new google.maps.InfoWindow({ 
    content: locations[i][0], 
    maxWidth: 160 
}); 
infowindow.open(map, marker);} 
} 

And this link doesn't have an answer for me

回答

2
<div id="googleMap"></div> 
<style> 
    #googleMap { 
    width: 100%; 
    height: 80%; 
    } 
</style> 
<script src="https://maps.googleapis.com/maps/api/js?callback=myMap" async defer></script> 
<script type="text/javascript"> 
function myMap() { 
    var mapProp= { 
    center:new google.maps.LatLng(36.109667, 43.3575), 
    zoom:9, 
    }; 
    var map=new google.maps.Map(document.getElementById("googleMap"), mapProp); 
    var locations = [ 
    [36.3518, 43.3793, "My location A"], 
    [35.7981, 43.2932, "My location B"], 
    [36.1791, 43.4000, "My location C"], 
    [36.3518, 43.3793, "My location D"], 
    [35.7981, 43.2932, "My location E"], 
    [36.1791, 43.4000, "My location F"], 
    [36.3518, 43.3793, "My location G"], 
    [35.7981, 43.2932, "My location H"], 
    [36.1791, 43.4000, "My location I"] 
    ]; 
    for (var i = 0; i < locations.length; i++) { 
    var marker = new google.maps.Marker({ 
     position: new google.maps.LatLng(locations[i][0], locations[i][1]), 
     map: map 
    }); 
    var infowindow = new google.maps.InfoWindow({ 
     content: locations[i][2], 
     maxWidth: 160 
    }); 
    infowindow.open(map, marker); 
    } 
} 
</script> 
+0

謝謝!我以後可能會有幾個問題,如果我在評論(這裏)中問他們可以嗎? –

+0

取決於它是一個額外的功能還是完全不同的問題。您也可以提出不同的問題,然後在此處添加新鏈接作爲評論 –