javascript - Ext Js 4 gmappanel change center dynamically -


i've simple gmappanel (extjs 4.1.1). how change "center" of map , refresh window center in new coordinate?

my code is:

ext.loader.setconfig({         enabled : true     }); ext.require(['ext.window.*', 'ext.ux.gmappanel']);  ext.define('am.view.gmapwindow.googlemap', { extend : 'ext.window.window', alias : 'widget.gmapw', autoshow : true, title : 'map', closeaction : 'hide', width : 460, height : 500, border : false, x : 40, y : 60, items : [{             layout : {                 type : 'hbox',                 align : 'stretch'             },             flex : 1,             items : [{                         xtype : 'textfield'                     }, {                         xtype : 'button',                          handler: function() { //-------------------- //modify here center  //geocodeaddr:'suisse romande, avenue de la gare, sion, svizzera' //---------------------                             }                     }]         }, {             width : 450,             layout : 'fit',             height : 450,             border : false,             items : {                 xtype : 'gmappanel',                 center : {                     geocodeaddr : '4 yawkey way, boston, ma, 02215-3409, usa'                  },                  markers : []             }         }] 

});

the map shown, if try change center editing

geocodeaddr

with following code

this.up('gmapw').down('gmappanel').center.geocodeaddr='suisse romande, avenue de la gare, sion, svizzera'; 

nothing happens.

any ideas?

thank you

if @ gmappanel.js, see in afterfirstlayout(), geocodeaddr used when creating map. setting after layout not going since afterfirstlayout() won't called again.

you should geocode address , use set center on map. following should work:

var map = this.gmap; var geocoder = new google.maps.geocoder(); var request = {address: 'suisse romande, avenue de la gare, sion, svizzera'}; var callback = function(geocoderresults, geocoderstatus) {     if(geocoderstatus === 'ok') {         var location = geocoderresults[0].geometry.location;         var latlng = new google.maps.latlng(location.lat(), location.lng());         map.setcenter(latlng);     } } geocoder.geocode(request,callback); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -