[OpenLayers-Dev] Capture feature events on different layers: Solution and Code (Controls and Handlers)
Hi list, I have done controls and handlers to handle events in features that are in different layers (with OpenLayers controls you only can handle events in a single layer, and that layer must be on the top), and as I received on mail requests to share my code, I decided to send it for the list. With an explanation how it works. Actually I made two controls, FeatureEventHandlerControl and DragFeatureControl and an handler (FeatureHandler) to help the FeatureEventHandlerControl. This two controls works pretty like the SelectFeature and DragFeature OpenLayers controls, but they work cross layers. They don't care about the layers. When you want to get an event from a feature, you must register that feature on the control, and when that event occurres you will be notified. For example: / Var dragControl = new Sapo.Control.DragFeatureControl([], { 'dragstart': { callback: function(feacture, pixel){/*do something*/} context: this} 'drag': { callback: function(feacture, pixel){/*do something*/} context: this} 'dragend': { callback: function(feacture, pixel){/*do something*/} context: this} } ); Var featureEvtHandler = new Sapo.Control.FeatureEventHandlers([], { 'click': { callback: function(feacture, pixel){/*do something*/} context: this} 'mouseover': { callback: function(feacture, pixel){/*do something*/} context: this} 'mouseout': { callback: function(feacture, pixel){/*do something*/} context: this} } ); Map.addControl(dragControl); Map.addControl(featureEvtHandler); dragControl.activate(); featureEvtHandler.activate(); Var layer1 = new OpenLayers.Layer.Vector("Markers", { projection: new OpenLayers.Projection("EPSG:4326"), styleMap: new OpenLayers.StyleMap({ externalGraphic: "http://openlayers.org/dev/img/marker-gold.png";, backgroundGraphic: "http://openlayers.org/dev/examples/marker_shadow.png";, graphicYOffset: -20, backgroundXOffset: 0, backgroundYOffset: -17, pointRadius: 10 }) } ); Var layer2 = new OpenLayers.Layer.Vector("Markers 2", { projection: new OpenLayers.Projection("EPSG:4326"), styleMap: new OpenLayers.StyleMap({ externalGraphic: "http://openlayers.org/dev/img/marker-gold.png";, backgroundGraphic: "http://openlayers.org/dev/examples/marker_shadow.png";, graphicYOffset: -20, backgroundXOffset: 0, backgroundYOffset: -17, pointRadius: 10 }) } ); Map.addLayer(layer1); Map.addLayer(layer2); Var feature1 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-1904105.3415234375, 4392319.753066596)); Var feature2 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-1504105.3415234375, 4392319.753066596)); Layer1.addFeatures([feature1]); Layer2.addFeatures([feature2]); dragControl.addFeature(feature1); featureEvtHandler.addFeature(feature2); //
[OpenLayers-Dev] Strategy.Save new events
Hi devs, http://trac.openlayers.org/ticket/1902 is an unassigned ticket with a patch implementing new features to the Strategy.Save. Comments are welcomed, Regards, -- Alexandre Dubé Mapgears www.mapgears.com ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev
[OpenLayers-Dev] Proxy with dev.openlayers.org
Hi devs, Some examples on sandboxes don't work because http://dev.openlayers.org/proxy/ doesn't exist. Could that be fixed ? -- Alexandre Dubé Mapgears www.mapgears.com ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev
Re: [OpenLayers-Dev] DeleteFeature Control
Alexandre Dube wrote: > Thanks Roald for the review. > > I just added some more user-friendly features to the control and > changed the state to review as you suggested. I guess it's almost > completed. The thing that bothers me the most is the fact that I had to > register 2 OL.Handlers.Box to be able to 2 different keyMasks : shiftKey > alone and shiftKey + ctrlKey. I don't want the user to be able to draw > a box without holding the shift key. It's more intuitive that way in my > opinion. So, could I have done this an other way ? > > Comments are welcomed, > > See a live example of the DeleteFeature control at http://dev.openlayers.org/sandbox/adube/openlayers/examples/deleteFeatures.html -- Alexandre Dubé Mapgears www.mapgears.com ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev
Re: [OpenLayers-Dev] New DragFeature Control and SelectFeatureControl cross layers. Want to share
Hi Andre, 2009/1/13 Andre Pereira de Matos : > I have made a Project with openlayers, and at some point I had to make a new > handler and a new control to provide draggable feature and handle events > like, click, mouseover, mouseout in features that was in different layers. > > The Openlayers control (DragFeature, SelectFeature) and handlers (Drag, > Feature) only works if the features are all in the same layer and the layer > is on the top. I have no experience with the DragFeature control, but I have created a solution for feature selection that works with multiple layers recently [1]. An example is also avaialable [2]. You may want to check this out, and I'd be interested to see your approach. Also, it would be cool to see if my approach also works with the DragFeature control. Regards, Andreas. [1] http://trac.openlayers.org/ticket/1666 [2] http://dev.openlayers.org/sandbox/ahocevar/singleroot/openlayers/examples/select-feature-multilayer.html -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev
Re: [OpenLayers-Dev] Map Initialization (was [GeoExt] Map widgets)
This is awesome! Thanks Tim. Andreas. On Wed, Jan 14, 2009 at 8:55 PM, Tim Coulter wrote: > FYI: > > http://trac.openlayers.org/ticket/1901 > > Tim > > -- > Tim Coulter > OpenGeo - http://www.opengeo.org > Expert service straight from the developers. > > On Wed, 2009-01-14 at 12:38 -0500, Tim Coulter wrote: >> Thanks for the feedback, Eric. CC'ing to the OL dev list. >> >> Back story for the OL developers: >> >> When working with Ext and OpenLayers, I realized that due to >> OpenLayer's >> Map class requiring a div on initialization, my code contained a >> circular dependency. The problem was that Ext's Viewport code needed >> things initialized before it laid out HTML elements for each >> component; >> on the other hand, OL needed HTML elements defined before it could >> create a map. Because they both needed each other, I was at an >> impasse. >> >> To get around this, I edited OpenLayers to not require a div on >> initialization. At the same time, I added the named argument >> "renderTo" >> to get rid of the reliance on positional arguments if >> rendering-on-initialization was required. >> >> http://trac.openlayers.org/changeset/8608 >> >> Examples of this code's use are here[1] and here[2]. Note that in the >> second case, I'm initializing a map with no parameters. >> >> The implementation (as far as arguments are concerned) is backwards >> compatible. You can still use the positional argument if you'd like >> to, >> but preference is given to renderTo. Neither are required. >> >> I'd be very interested if this is helpful for others in the community. >> I'd also be happy to give more back story if needed. >> >> On the GeoExt list (geo...@lists.opengoe.org), Eric Lemoine asked the >> question: >> >> > With your new OpenLayers code, can one do: >> > >> > 1 map = new OpenLayers.Map(); >> > 2 map.addLayer(new OpenLayers.Layer.WMS()); >> > 3 map.render("map-div") >> >> That was the intention, yes. Aside from needing to call some form of >> setCenter/zoomToExtent/etc. after render(), the above should work. >> >> He brought up a good bug: >> >> > I'm concerned with addLayer failing if maxResolution is "auto" - the >> > map doesn't have a div at addLayer time, so resolutions can't be >> > calculated. Even if I'm correct, that may be ok, users should just >> be >> > warned. >> >> Is the default value for maxResolution "auto"? If not, I haven't run >> into a case where this happens. Can you provide an example? >> >> What does everyone think? I plan on opening a ticket today and >> submitting a patch to get this discussion going there. >> >> Tim >> >> [1] >> http://dev.openlayers.org/sandbox/tcoulter/teleporter/examples/teleportation.html >> [2] >> http://dev.openlayers.org/sandbox/tcoulter/teleporter/examples/late-render.html >> >> On Wed, 2009-01-14 at 07:34 +0100, Eric Lemoine wrote: >> > On Tue, Jan 13, 2009 at 6:55 PM, Tim Coulter >> wrote: >> > > 2) It supports both passing an already-created map (as per my last >> > > email), as well as allowing a configuration to be passed as >> this.map. In >> > > the latter case, the map is created for the developer by the >> MapPanel. >> > >> > I like the idea of having the map option either be a Map instance or >> a >> > Map config. >> > >> > > 3) I've removed synonymous functions. I've also removed TimS's >> layer and >> > > control convenience functions/features; I think these could be put >> back >> > > in, though if OpenLayers allows the "layers" and "controls" named >> > > parameters (I know "controls" is there), then there may be no need >> for >> > > MapPanel to handle it. >> > >> > Adding support to OpenLayers for a "layers" map option would be very >> > useful I think. Otherwise, if I'm correct with the above >> > "maxResolution set to auto" issue, we'd need the MapPanel to trigger >> > an event to know when layers can be safely added to the map. >> > >> > In any way, I think we'd need our map panel to trigger events, at >> > least one to tell the world that the map instance is created. This >> > discussed with Andreas and Bart, they even started coding things >> > around that if I remember correctly. >> > >> > > 4) I haven't yet gotten the changes to Map.js looked at or >> approved by >> > > the OpenLayers folks, so if it's something we'd like to use, we >> should >> > > start some conversation over there. (I know a lot of you guys are >> on >> > > this list. :) ) >> > > >> > > Given that the circular dependencies in Map.js are removed, and >> the >> > > MapPanel accepts a map as well as a configuration, it more >> reflects my >> > > coding style while (I think) supporting everyone else's. >> > > >> > > Let me know what you guys think. I'm really interested in knowing >> if >> > > others find this useful. >> > >> > Thanks Tim, >> > >> > -- >> > Eric >> > >> > >> > -- >> > Archive: >> http://lists.opengeo.org/geoext/archive/2009/01/1231915041656 >> > To unsubscribe send an email with subject "unsubscribe" to >> geo...@lists.opengeo.org. Please contact >
[OpenLayers-Dev] new Strategy.OptionsByZoom
Hi devs, http://trac.openlayers.org/ticket/1905 is an unassigned ticket implementing a new feature : Strategy.OptionsByZoom See live examples of use : (working) http://dev4.mapgears.com/bdga/options-by-zoom-bdga.html (missing different data sources) http://dev.openlayers.org/sandbox/adube/openlayers/examples/options-by-zoom.html Comments are welcomed, Regards, -- Alexandre Dubé Mapgears www.mapgears.com ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev
[OpenLayers-Dev] WFS protocol
Hey- We've done quite a bit of work toward a working WFS protocol in the topp/wfs sandbox. The work includes (fairly significant) changes to filters and formats and will need to be divided into a few tickets at least. The protocol will likely not satisfy *all* cases for WFS, but I think it is important that we get something working in the trunk. Additional enhancements can come later. Alexandre Dube and I will be meeting on #openlayers at 16:30 GMT, Tues Jan 20 (next week) to talk about dividing up responsibilities for making patches and getting this in the trunk. If anybody else is able to help, please join us. Tim -- Tim Schaub OpenGeo - http://opengeo.org Expert service straight from the developers. ___ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev