PDA

View Full Version : Can't call google api v3 function ?



coffeemonster
31 Oct 2011, 4:48 AM
Hi,

I am trying to make some simple map function like changing the mapTypeId or setting a new center position.

However I can't seem to get the functions "map.map.setCenter(xxx)" to work, even though that seems to be the agreed upon way of doing it on the forum?

In fact all standard Google API v.3 functions I call seem to give me the same error message



Does anyone have any idea about what I am doing wrong ?


Ext.setup({ onReady: function() {

var mapCenter = function(){
var pnt = new google.maps.LatLng(60, 105);
map.map.setCenter(pnt);
};

var MyLatLng = new google.maps.LatLng(55.676033, 12.568923);
var mapType;
mapType = google.maps.MapTypeId.ROADMAP;
var zoomLevel = 15;
var map;


map = new Ext.Panel({
dockedItems: [{
xtype: 'toolbar',
ui: 'light',
title: 'GeoSpot',
layout: 'fit',
items: [
{
text: 'RoadMap',
ui: 'round',
handler: mapCenter
}]
}],


items: [{
xtype: 'map',
title: 'map',
useCurrentLocation: true,
mapOptions : {
center : MyLatLng,
zoom : zoomLevel,
mapTypeId : mapType,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DEFAULT
},
navigationControl: false,
}
}]
});






var mainPanel = new Ext.Panel({
layout: 'card',
fullscreen : true,
items: [map]
});
}
});

The consol error I get in Chrome is:

"Uncaught TypeError: Cannot call method 'setCenter' of undefined"

Hope you can help me out /:)

All the best
Peter the ~o)-monster