I am trying to create some code in GeoExt that will allow me to centre that map layer I am viewing to coordinates that have been submitted through a formPanel. I would have thought that this would have been fairly straightforward but this is proving to be quite troublesome and I am wondering if any of you guys could help?
So far I have created the the panel with 2 boxes to accept the eastings and northings but can't work out how to get the values that have been submitted to actually move the image.
The code I have cobbled together this far is:
formPanelCoord = new GeoExt.form.FormPanel({
border: true,
layout: 'anchor',
bodyStyle:'padding: 20px',
items: [{
xtype: "textfield",
width: 100,
fieldLabel: "Easting",
name: "search_lc",
value: "",
emptyText:'Easting',
allowblank: false
},
{
xtype: "textfield",
width: 100,
fieldLabel: "Northing",
name: "search_lc",
value: "",
emptyText:'Northing',
allowblank: false
}],
listeners: {
actioncomplete: function(form, action) {
features = action.response.features;
console.log(features.length)
}
}
});
formPanelCoord.addButton({
text:"Go to Coord",
handler:function() {
console.log(formPanelCoord);
//alert(formPanelCoord.items.items[0].getValue());
//alert(formPanelCoord.items.items[1].getValue());
formPanelCoord.items.items[0].getValue();
formPanelCoord.items.items[1].getValue();
//function recentreMap (form) {
var easting = from.Easting.value;
var northing = form.Northing.value;
//var easting = formPanelCoord.items.items[0].value;
//var northing = formPanelCoord.items.items[1].value;
map.setCenter(new OpenLayers.LonLat(easting,northing));
formPanelCoord.addButton({
text:"Go to Coord",
handler:function() {
this.search();
},
scope:formPanelCoord
});
//this.search();
},
scope:formPanelCoord
});
Any help gratefully received!