o mapa do google com vários marcadores não está aparecendo
Eu quero exibir vários marcadores no mapa do google.Eu estou usando para cada loop para percorrer a lista de modelos que contém latitude e longitude.Mas a função é chamada e não mostra um mapa.
código:
<div id="map_canvas" style="width: 80%; height: 80%"> </div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?
sensor=false"></script>
<script type="text/javascript">
$(document).ready(function () {
alert("working");
var map;
var locations = [];
var options = {
zoom: 14,
center: new google.maps.LatLng(0, 0),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map($('#map_canvas')[0], options);
@* This is the razor loop *@
@foreach (var item in Model) {
<text>
locations.push(item.latitude, item.longitude);
</text>
}
var i;
for (i = 0; i <= locations.length; i++) {
var latlng = new google.maps.LatLng(locations[i][0], locations[i][1]);
var marker = new google.maps.Marker({
position: latlng,
map: map,
});
}
});
</script>