[OpenLayers-Users] How do I draw a box, retreive map coordinates, and pass to a python function?
Phil Scadden
p.scadden at gns.cri.nz
Tue Jul 22 15:00:20 PDT 2014
okay, here is some outline (what I do for searching). Overview:
Create a vector layer (selectedLayer) in which drawing occurs.
Use a drawfeature control to do the drawing.
When feature added to to drawcontrol, extract the geometry, call server
with a callback to handle the response.
the code:
selectedLayer = new OpenLayers.Layer.Vector("Selected Layer", {
wrapDateLine: true,
displayOutsideMaxExtent: true,
displayInLayerSwitcher: false,
});
map.addLayer(selectedLayer); (top layer)
ctrl= new OpenLayers.Control.DrawFeature(selectedLayer,
OpenLayers.Handler.Polygon, {
geodesic: true, // stuff for managing drawing across
180 line
handlerOptions: {
citeCompliant: false
}
});
// you can use different handler other than polygon for other geometries
ctrl.events.register("featureadded", this, function (e) {
Ext.Ajax.request({ // i am using Ext, but you can use any ajax
wrapper you like
url:'mypythoncode',
method:'GET',
success:function(response){
// process the response
},
params:{
geometry:serialize(e.feature.geometry) // you need to
write serialize to your taste to format the geometry
id: new Date().getTime(); // avoid browser caching
}
});
That should get you started.
Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.
More information about the Users
mailing list