0

I need to have all of the infoWindows open, I'm would prefer the answer to be in C# but I tried this

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

Roshna Omer
  • 687
  • 1
  • 11
  • 20

1 Answers1

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>
Emmanuel Delay
  • 3,619
  • 1
  • 11
  • 17
  • Thank you! I may have a few questions later, is it ok if I ask them in the comments (here)? – Roshna Omer Jun 19 '17 at 09:48
  • Depends if it's an extra feature or a completely different question. You could also ask a different question and and put the new link as a comment here – Emmanuel Delay Jun 19 '17 at 11:34