[OpenLayers-Users] Drawfeature question

Ryan Williams rwilliams at paqinteractive.com
Fri Feb 24 10:36:01 EST 2012


Hi Robert,

What are you using to call the function newcrop()?
A button in the body, defined in html like... <input type="button" 
........   ?, or radio buttons in a similar way?
Or from a button or handler in Ext, GeoExt?
My guess is that the map isn't getting the style for the mouse pointer 
updated when you activate the tool, but once you click on the map the 
style gets updated.
Everything I've done with adding an editing / draw tool is activated 
from an ext.button or GeoExt.Action. Each of those activate the draw 
feature and the mouse pointer looks like the editing tool immediately.

Looking at the OpenLayers examples, there's a really similar one at 
http://openlayers.org/dev/examples/draw-feature.html , and another at 
http://openlayers.org/dev/examples/donut.html
What I see different there is that they don't define displayClass or title.
I suppose it could be related to the displayClass setting since it looks 
like that displayClass is intended for use when you add the control to a 
panel (like a custom toolbar). That's really just a guess though.
Generally though it looks like the code should work; and it sounds like 
it is, it just isn't updating the map's mouse pointer style when the 
pointer enters the map again after activating the control?

- Ryan

On 2/22/2012 8:11 PM, Robert Sanson wrote:
> I have a map where I load a vector polygon layer (crops) with source data coming from a database in WKT format. The layer is loaded when a button on the interface is pressed. I add DrawFeature, ModifyFeature and SelectFeature controls to the layer, which are selectively activated when a button on the interface is pressed.
>
> ...
> map.addLayer(crops);
> cropControls = {
>                  dpoly: new OpenLayers.Control.DrawFeature(crops,OpenLayers.Handler.Polygon,
> 			{displayClass: "olControlDrawFeaturePoint", title: "Draw Features", handlerOptions: {holeModifier: "altKey"}}),
>                  modify: new OpenLayers.Control.ModifyFeature(crops,{displayClass: "olControlModifyFeature", title: "Modify Features"}),
>                  delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {feature.attributes.pstate = "del";
>                                                                                                   feature.style = del_style;
>                                                                                                   crops.drawFeature(feature);
>                                                                                                   }
> 											}
> 									)
> };
> for(var key in cropControls) {
>                  map.addControl(cropControls[key]);
> }
> ...
> function newcrop() {
>      var val = "dpoly";
>      for(key in cropControls) {
>                  var crcontrol = cropControls[key];
>                  if(val == key) {
>                      crcontrol.activate();
>                  } else {
>                      crcontrol.deactivate();
>                  }
>      }
>      crops.onFeatureInsert = function(feature) {...}
> }
>
> My problem is that the DrawFeature control does not display the draw symbol (default circle) until after I digitise the first point.
>
> How can I get the circle showing underneath my mouse cursor as soon as the DrawFeature control is activated?
>
> Many thanks,
>
> Robert Sanson
>
>
>
> This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.
>
> This message has been scanned for Malware and Viruses by Websense Hosted Security.
> www.websense.com
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>

-- 
Ryan Williams
GIS Analyst / Programmer
PAQ Interactive Inc.
rwilliams at paqinteractive.com
217-762-7955



More information about the Users mailing list