I am banging my head against a wall with this. I want to display the map centre coordinates of on screen in a div. The map has a kml layer. When I try to use getCentre() to get the lat & long I just get this error:
Object #<xi> has no method 'getCentre'
I'm using the following code to generate the map, with getCentre() at the end:
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(58.401712, 14.577025),
zoom: 4,
overviewMapControl: true,
overviewMapControlOptions: {
opened: true,
},
mapTypeId: google.maps.MapTypeId.SATELLITE
});
loadKmlLayer(src, map);
}
function loadKmlLayer(src, map) {
var kmlLayer = new google.maps.KmlLayer(src, {
suppressInfoWindows: true,
preserveViewport: false,
map: map,
});
var coords = map.getCentre();