簡體   English   中英

從多個標記打開的所有InfoWindows,谷歌地圖

[英]All InfoWindows Opened from Multiple Markers, google maps

我需要打開所有的infoWindows,我希望答案在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);}
}

而且這個鏈接對我沒有答案

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM