PDA

View Full Version : Problem with Google maps



tombal93
30 Sep 2010, 11:36 AM
Hello,

I want to use gmap to get the latitude and longitude of the center dynamicaly changed in 2 fields in a form

I read some threads and i think that is a scope problem but where do i need to specify ?

Ext.getCmp seems to get the object ?



function opengmap() {


var mapwin;

if(!mapwin){

mapwin = new Ext.Window({
layout: 'auto',
title: 'Géolocalisation du prestataire',
closeAction: 'hide',
width:420,
height:500,
modal:true,
items: [


{
xtype: 'panel',
layout: 'auto',
style: 'margin-left:5px',
labelAlign: 'left',
width:400,
height:350,
layoutConfig: {
labelSeparator: ' '
},
items: [
{

xtype: 'gmappanel',
zoomLevel: 14,
id:'macarte',
gmapType: 'map',
mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
setCenter: {
geoCodeAddr: '4 Yawkey Way, Boston, MA, 02215-3409, USA',
marker: {title: 'Fenway Park'}
},
markers: [{
lat: 42.339641,
lng: -71.094224,
marker: {title: 'Boston Museum of Fine Arts'},
listeners: {
click: function(e){
Ext.Msg.alert('Its fine', 'and its art.');
}
}
},{
lat: 42.339419,
lng: -71.09077,
marker: {title: 'Northeastern University'}
}]
}
]
},




{
xtype: 'form',
padding: 5,
unstyled: true,
headerAsText: false,
buttonAlign: 'center',
border: false,
animCollapse: false,
layout: 'form',
title: 'My Form',
style:'padding-top:10px',
layoutConfig: {
labelSeparator: ' '
},
items: [
{
xtype: 'textfield',
value: '',
readOnly: true,
fieldLabel: 'Latitude',
name: 'latitude',
id: 'latitude'
},
{
xtype: 'textfield',
allowBlank: false,
fieldLabel: 'Longitude',
name: 'longitude',
id: 'longitude'
},
{
xtype: 'button',
type: 'submit',
text: 'Enregistrer',
}
]

}







]
});


}

mapwin.show();


var theMap = Ext.getCmp('macarte');
var rmap = theMap.getMap();

alert(theMap.getCenterLatLng()); // i have error : ll is null


}


Thanks for your help