Ответ 1
Я обновил вашу скрипку здесь: http://jsfiddle.net/KwayW/1/
Теперь он работает как ожидалось.
Здесь полный код (сохраните его как test.html и откройте в браузере):
<style>#map_canvas { width:500px; height: 400px; }</style>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<div id="map_canvas"></div>
<script>
var map;
var markersArray = [];
var image = 'img/';
var bounds = new google.maps.LatLngBounds();
var loc;
function init(){
var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
loc = new google.maps.LatLng("45.478294","9.123949");
bounds.extend(loc);
addMarker(loc, 'Event A', "active");
loc = new google.maps.LatLng("50.83417876788752","4.298325777053833");
bounds.extend(loc);
addMarker(loc, 'Event B', "active");
loc = new google.maps.LatLng("41.3887035","2.1807378");
bounds.extend(loc);
addMarker(loc, 'Event C', "active");
map.fitBounds(bounds);
map.panToBounds(bounds);
}
function addMarker(location, name, active) {
var marker = new google.maps.Marker({
position: location,
map: map,
title: name,
status: active
});
}
$(function(){ init(); });
</script>