ich mehrere Standorte auf einer Google-Karte angezeigt werden soll, lesen, aber es gibt den FehlerUncaught Typeerror: kann Eigenschaft ‚fitBounds‘ undefinierter mit google map (markerWithlabel js)
"Uncaught TypeError: Cannot read property 'fitBounds' of undefined"
aber es für ein einzelnes Werk Lage.
Mein JavaScript
jQuery(document).ready(function($) {
var map;
var bounds = [];
function initMap() {
var latlng = new google.maps.LatLng(<?php echo $map_lat;?>,<?php echo $map_lng;?>);
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 10,
center: latlng
});
var marker = new MarkerWithLabel({
position:latlng,
draggable: false,
raiseOnDrag: true,
map:map,
labelContent:"test",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75}
});
bound.push(marker);
}
google.maps.event.addDomListener(window, 'load', initMap());
map.fitBounds(bounds); //binding all location on the map.
});
Bitte geben Sie ein Beispiel [Minimal, vollständig, getestet und lesbar] (http://stackoverflow.com/help/mcve) an, das das Problem (ohne PHP) veranschaulicht. – geocodezip
Es gibt keine 'bounds' in dem entsandten Code definiert (eigentlich ist da, aber es ist ein Array, kein' google.maps.LatLngBounds' Objekt. – geocodezip