[OpenLayers-Users] Scalebar doesn't work
Hello, I try to make a scalebar but without success. My scalebar doesn't show the lines. Bild (Metafile) This is my code. var scalebar = new OpenLayers.Control.ScaleBar({ div: document.getElementById(kartenElemente), displaySystem: 'metric', divisions: '2', subdivisions: '4' }); map.addControl(scalebar); I use OpenLayers 2.9. Hope that somebody can help me. Greetings Hanno Rahn -- Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen Fachstelle Geoinformatik Grüental, Postfach CH-8820 Wädenswil Tel +41 (0)58 934 5592 Fax +41 (0)58 934 5580 hanno.r...@zhaw.ch www.iunr.zhaw.ch/geoinformatik ole0.bmp___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
[OpenLayers-Users] IE6 / OpenLayers / Path DrawFeature and DoubleClicks
Greetings, I am working with OpenLayers and IE6 (which is the required SOE for the project) and have noticed that mouse doubleclicks are not being captured correctly when drawing a Path from an OpenLayers.Control.DrawFeature if another element is drawn to any layer from a sketchmodified event. From IE in the above situation the Path is drawn (which has a circle dynamically drawn round it using the sketchmodified event to call the OpenLayers.Layer.Vector.addFeatures method) but requires a single click immediately followed by a double click to terminate the Path. If the addFeatures call is not made (the circle is not drawn ) behavior is as normal. The code works as expected in Chrome. Has anyone dealt with this behavior before? Any help would really be appreciated. Cheers, James Sewell LISAsoft Developer +61 (3) 8680 3200 / +61 414 688 892 ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
[OpenLayers-Users] IE6 / OpenLayers / FeatureModified
Greetings, I am working with OpenLayers and IE6 (which is the required SOE for the project) and have noticed that I can't have more than one active OpenLayers.Control.ModifyFeature at any time. The code works as expected in Chrome. I am creating a ModifyFeature for each layer and then activating these when a dummy Modify button is clicked. A snippet from my code: var modifyControls = [ new OpenLayers.Control.ModifyFeature(layer1); new OpenLayers.Control.ModifyFeature(layer2) new OpenLayers.Control.ModifyFeature(layer3) new OpenLayers.Control.ModifyFeature(layer4); ]; function activateModifyTools() { for (var i=0; imodifyControls.length; i++) { modifyControls[i].activate(); } } This results in only the layer4 ModifyFeature being active. Please note I have tried simpler code which just creates then activates each ModifyFeature with the same result. Has anyone dealt with this behavior before? Any help would really be appreciated. Cheers, James Sewell LISAsoft Developer +61 (3) 8680 3200 / +61 414 688 892 ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
[OpenLayers-Users] Click to Add a feature with Custom Icon and Label
Hello, i am new to openlayers and work by experimenting in the code in examples. I had already posted my request twice but no response came :-(, may be my question was t basic. However i tried , and after release of 2.9 i was able to get some success. basically combining the code of Click example ( Click.HTML) and the marker-shadow.html example i was able to achieve following: 1. Click on the map to add any number of vector markers with a fixed style and label. 2. Drag any feature Now i want to be able to change the markers label and icon (may be selecting it from a html drop-down list for icon and an input box for label) once i click on the map. The only way is to define a custom style. I have defined a custom style but the vector markers shape and label remain the same. What is the problem? i cannot figure out. Any help is more than needed. Thanks. The code is as following: I want to change the custom style inside the click event . (highlighted in yellow) html xmlns=http://www.w3.org/1999/xhtml; head titleOpenLayers Click Event Example/title link rel=stylesheet href=../theme/default/style.css type=text/css / link rel=stylesheet href=style.css type=text/css / script src=../lib/OpenLayers.js/script script type=text/javascript var SHADOW_Z_INDEX = 10; var MARKER_Z_INDEX = 11; var DIAMETER = 200; var NUMBER_OF_FEATURES = 15; var map,layer; function init(){ map = new OpenLayers.Map('map'); var ol_wms = new OpenLayers.Layer.WMS( OpenLayers WMS, http://labs.metacarta.com/wms/vmap0?;, {layers: 'basic'} ); var jpl_wms = new OpenLayers.Layer.WMS( NASA Global Mosaic, http://t1.hypercube.telascience.org/cgi-bin/landsat7;, {layers: landsat7}); jpl_wms.setVisibility(false); map.addLayers([ol_wms, jpl_wms]); map.addControl(new OpenLayers.Control.LayerSwitcher()); // map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.zoomToMaxExtent(); layer = new OpenLayers.Layer.Vector( Marker Drop Shadows, { styleMap: new OpenLayers.StyleMap({ //label: ${foo}, // label will be foo attribute value graphicYOffset: -25, // shift graphic up 28 pixels label: A, // Set the external graphic and background graphic images. externalGraphic: ../img/marker-gold.png, backgroundGraphic: ./marker_shadow.png, // Makes sure the background graphic is placed correctly relative // to the external graphic. backgroundXOffset: -2, backgroundYOffset: -20, // Set the z-indexes of both graphics to make sure the background // graphics stay in the background (shadows on top of markers looks // odd; let's not do that). graphicZIndex: MARKER_Z_INDEX, backgroundGraphicZIndex: SHADOW_Z_INDEX, pointRadius: 10 }), isBaseLayer: false, rendererOptions: {yOrdering: true} } ); map.addLayers([layer]); // Add a drag feature control to move features around. var dragFeature = new OpenLayers.Control.DragFeature(layer); map.addControl(dragFeature); dragFeature.activate(); var click = new OpenLayers.Control.Click(); map.addControl(click); click.activate(); } OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, initialize: function(options) { this.handlerOptions = OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler = new OpenLayers.Handler.Click( this, { 'click': this.trigger }, this.handlerOptions ); }, trigger: function(e) { var lonlat = map.getLonLatFromViewPortPx(e.xy); //alert(You clicked near + lonlat.lat + N, +lonlat.lon + E);
Re: [OpenLayers-Users] Click to Add a feature with Custom Icon and Label
On Friday, April 30, 2010, Subhani Minhas subhanimin...@gmail.com wrote: Hello, i am new to openlayers and work by experimenting in the code in examples. I had already posted my request twice but no response came :-(, may be my question was t basic. However i tried , and after release of 2.9 i was able to get some success. basically combining the code of Click example ( Click.HTML) and the marker-shadow.html example i was able to achieve following: 1. Click on the map to add any number of vector markers with a fixed style and label. 2. Drag any feature Now i want to be able to change the markers label and icon (may be selecting it from a html drop-down list for icon and an input box for label) once i click on the map. The only way is to define a custom style. I have defined a custom style but the vector markers shape and label remain the same. What is the problem? i cannot figure out. Any help is more than needed. Thanks. The code is as following: I want to change the custom style inside the click event . (highlighted in yellow) html xmlns=http://www.w3.org/1999/xhtml; head titleOpenLayers Click Event Example/title link rel=stylesheet href=../theme/default/style.css type=text/css / link rel=stylesheet href=style.css type=text/css / script src=../lib/OpenLayers.js/script script type=text/javascript var SHADOW_Z_INDEX = 10; var MARKER_Z_INDEX = 11; var DIAMETER = 200; var NUMBER_OF_FEATURES = 15; var map,layer; function init(){ map = new OpenLayers.Map('map'); var ol_wms = new OpenLayers.Layer.WMS( OpenLayers WMS, http://labs.metacarta.com/wms/vmap0?;, {layers: 'basic'} ); var jpl_wms = new OpenLayers.Layer.WMS( NASA Global Mosaic, http://t1.hypercube.telascience.org/cgi-bin/landsat7;, {layers: landsat7}); jpl_wms.setVisibility(false); map.addLayers([ol_wms, jpl_wms]); map.addControl(new OpenLayers.Control.LayerSwitcher()); // map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.zoomToMaxExtent(); layer = new OpenLayers.Layer.Vector( Marker Drop Shadows, { styleMap: new OpenLayers.StyleMap({ //label: ${foo}, // label will be foo attribute value graphicYOffset: -25, // shift graphic up 28 pixels label: A, // Set the external graphic and background graphic images. externalGraphic: ../img/marker-gold.png, backgroundGraphic: ./marker_shadow.png, // Makes sure the background graphic is placed correctly relative // to the external graphic. backgroundXOffset: -2, backgroundYOffset: -20, // Set the z-indexes of both graphics to make sure the background // graphics stay in the background (shadows on top of markers looks // odd; let's not do that). graphicZIndex: MARKER_Z_INDEX, backgroundGraphicZIndex: SHADOW_Z_INDEX, pointRadius: 10 }), isBaseLayer: false, rendererOptions: {yOrdering: true} } ); map.addLayers([layer]); // Add a drag feature control to move features around. var dragFeature = new OpenLayers.Control.DragFeature(layer); map.addControl(dragFeature); dragFeature.activate(); var click = new OpenLayers.Control.Click(); map.addControl(click); click.activate(); } OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, initialize: function(options) { this.handlerOptions = OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler = new OpenLayers.Handler.Click( this, { 'click': this.trigger }, this.handlerOptions ); }, trigger: function(e) {
Re: [OpenLayers-Users] IE6 / OpenLayers / FeatureModified
Hi, On Fri, Apr 30, 2010 at 8:23 AM, james.sew...@lisasoft.com james.sew...@lisasoft.com wrote: I am working with OpenLayers and IE6 (which is the required SOE for the project) and have noticed that I can’t have more than one active OpenLayers.Control.ModifyFeature at any time. The code works as expected in Chrome. Which is a surprise to me :-). Control.ModifyFeature is not supposed if multiple instances are active at a time. It would, however, be simple to add multiple layer support to Control.ModifyFeature, like we have for Control.SelectFeature already. Patches are welcome. Another thing you could try: configure one ModifyFeature control with a SelectFeature control that is configured with multiple layers. Maybe this will help you to select features from different layers, and if you're lucky you can even modify them afterwards. Regards, Andreas. I am creating a ModifyFeature for each layer and then activating these when a dummy Modify button is clicked. A snippet from my code: var modifyControls = [ new OpenLayers.Control.ModifyFeature(layer1); new OpenLayers.Control.ModifyFeature(layer2) new OpenLayers.Control.ModifyFeature(layer3) new OpenLayers.Control.ModifyFeature(layer4); ]; function activateModifyTools() { for (var i=0; imodifyControls.length; i++) { modifyControls[i].activate(); } } This results in only the layer4 ModifyFeature being active. Please note I have tried simpler code which just creates then activates each ModifyFeature with the same result. Has anyone dealt with this behavior before? Any help would really be appreciated. Cheers, James Sewell LISAsoft Developer +61 (3) 8680 3200 / +61 414 688 892 ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] IE6 / OpenLayers / Path DrawFeature and DoubleClicks
Hi, On Fri, Apr 30, 2010 at 8:23 AM, james.sew...@lisasoft.com james.sew...@lisasoft.com wrote: I am working with OpenLayers and IE6 (which is the required SOE for the project) and have noticed that mouse doubleclicks are not being captured correctly when drawing a Path from an OpenLayers.Control.DrawFeature if another element is drawn to any layer from a sketchmodified event. I think the if part in the above sentence screws your application. This sounds like an application issue. You could try to draw the other element in the sketchmodified handler using setTimeout. If that does not work, try to create a minimal example that shows the issues, so it will be easier for others to help. Regards, Andreas. From IE in the above situation the Path is drawn (which has a circle dynamically drawn round it using the sketchmodified event to call the OpenLayers.Layer.Vector.addFeatures method) but requires a single click immediately followed by a double click to terminate the Path. If the addFeatures call is not made (the circle is not drawn ) behavior is as normal. The code works as expected in Chrome. Has anyone dealt with this behavior before? Any help would really be appreciated. Cheers, James Sewell LISAsoft Developer +61 (3) 8680 3200 / +61 414 688 892 ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] scaleline in lon/lat projection
Hi Andreas, With the new patch I attached to #1890, you should see the behavior you would expect. The reason is that we now measure in W-E direction, which makes more sense for most projections I have applied your patch and now it works great. Thanks a lot for your kind support! My questions are also: 1. What do you think about updating OpenLayers.INCHES_PER_UNIT instead of calculating N-S or W-E geodesic distances for calibrating the scale line control. See the discussion in #2600. My new patch adds a getGeodesicPixelSize method to the map. Width and height of the geodesic measurement of this pixel will be different. OpenLayers.INCHES_PER_UNIT is a global constant which should not be changed, because it is just there to convert between different units. Ok, now I get the point. Although if you think of converting degrees to inches or meters I would still argue it is not a constant... How would you calibrate the scaleline with your approach? There will still be a difference in measuring your unit in N-S and W-E direction on the map, especially in EPSG:4326. And the distance will also be different at every pixel on the map. I think that using a W-E measurement can be justified because we display the scaleline as horizontal line, which is W-E in most common projections. But still - if you zoom out far, the scaleline will only be accurate around the center of the map viewport. I was using the latitude of a map center to get the length of the given parallel in inches and than I was updating OpenLayers.INCHES_PER_UNIT. It seemed that the scale line control listened to these updates as it was adjusting itself when moving in N-S direction. Since parallels have W-E direction, so in fact the result was the same as in your patch, despite possibilities of breaking some other measurements and calculations which were using OpenLayers.INCHES_PER_UNIT. I understand that there are differences in W-E and N-S measurements and I agree that W-E usually makes more sense for the scale line (as scale line is horizontal). Although scaleline in both directions (kind of a scaleCross ??? could be an interesting approach...) Another thing I would consider is calculating W-E Vincenty distance not in the center of a map but in the bottom of a map, where the scaleline is usually placed. Usually (probably?) when users want to use scaleline to measure distance they pan the map so that the scaleline fits the measured object. In other words, scaleline could (???) be placed where it is more correct... But this is just and idea. On the other hand this will cause bigger errors for applying this scaleline to the upper parts of the map. I understand that each solution has its own pros and cons. Note that our geodesic measurement of distances (Vincenty) measures the distance between two coordinates on an ellipsoid, instead of the map. Applying this to ScaleLine and Scale means that instead of using the map resolution (which is map units per pixel), we use the ellipsoid distance of a pixel edge. 2. If you apply a patch that changes the scale line control to do a West-East measurement instead what will happen if you drag your map beyond -180/180 longitudes? Vincenty works fine in that case. Right. 3. Do you have any idea whether MapFish will also adopt geodesic scale bar functionality? MapFish uses OpenLayers, so it is just a matter of using the geodesic option. Hmm, so I must be doing something wrong. Having applied your patch and having set both scaleline and scale controls to geodesic: true these work fine now. But the scaleline attached to a PDF generated with GeoServer PDF printing module still shows a wrong scale line. Or is it because I use GeoServer PDF instead of the source MapFish...? Regards, Jan Burdziej ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] Spatial Filter parameter for WFS GetFeature
Hi, The Spatial filters are not working within WFS. How come nobody knows how to make it work? How can I give the data for DWITHIN filter? -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Spatial-Filter-parameter-for-WFS-GetFeature-tp4968446p4985464.html Sent from the OpenLayers Users mailing list archive at Nabble.com. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] scaleline in lon/lat projection
Hi, On Fri, Apr 30, 2010 at 2:02 PM, Jan Burdziej j...@umk.pl wrote: See the discussion in #2600. My new patch adds a getGeodesicPixelSize method to the map. Width and height of the geodesic measurement of this pixel will be different. OpenLayers.INCHES_PER_UNIT is a global constant which should not be changed, because it is just there to convert between different units. Ok, now I get the point. Although if you think of converting degrees to inches or meters I would still argue it is not a constant... Well, the metric length measurement system is defined based on the earth's perimeter. And the earth's perimeter is divided up into 360 degrees. So it is a perfect constant as long as you don't measure in projeted maps. 3. Do you have any idea whether MapFish will also adopt geodesic scale bar functionality? MapFish uses OpenLayers, so it is just a matter of using the geodesic option. Hmm, so I must be doing something wrong. Having applied your patch and having set both scaleline and scale controls to geodesic: true these work fine now. But the scaleline attached to a PDF generated with GeoServer PDF printing module still shows a wrong scale line. Or is it because I use GeoServer PDF instead of the source MapFish...? The print module calculates the scale from the map resoultion, it is not taken from OpenLayers. This is in the print module code, so it makes no difference whether you run it as GeoServer extension or directly within Mapfish. Regards, Andreas. -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
[OpenLayers-Users] show only specific objects, wms
Hy all, I use GeoServer with OpenLayers. I have a WMS Layer with many kinds types of objects. How can I show only for example object whose attribut has a special value? I know I can create SLD so that it shows what I need. But the problem ist that I have about 1000 different attribut values. And I can't create 1000 SLD documents... I hope you understood my problem... Is this possible with a WMS Layer? Or is there a way I can change the SLD on runtime? cheers David -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/show-only-specific-objects-wms-tp4986382p4986382.html Sent from the OpenLayers Users mailing list archive at Nabble.com. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] show only specific objects, wms
Hi, You can do it on runtime with layerWMS.mergeNewParams({ SLD_BODY : ...sld_body... }); I use this way to highlight a choosen country http://gis.ibbeck.de/OLClient/examples/wms_sld_world.asp Arnd -Ursprüngliche Nachricht- Von: users-boun...@openlayers.org [mailto:users-boun...@openlayers.org] Im Auftrag von t...@f!t Gesendet: Freitag, 30. April 2010 17:47 An: users@openlayers.org Betreff: [OpenLayers-Users] show only specific objects, wms Hy all, I use GeoServer with OpenLayers. I have a WMS Layer with many kinds types of objects. How can I show only for example object whose attribut has a special value? I know I can create SLD so that it shows what I need. But the problem ist that I have about 1000 different attribut values. And I can't create 1000 SLD documents... I hope you understood my problem... Is this possible with a WMS Layer? Or is there a way I can change the SLD on runtime? cheers David -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/show-only-specific-objects-wms-tp4986 382p4986382.html Sent from the OpenLayers Users mailing list archive at Nabble.com. ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
[OpenLayers-Users] KML over VirtualEarth Map doesn't display or has a shift
Hi! I'm trying to lay an KML over VirtualEarth Map in OpenLayers, but it either does'nt display anything or KML points have a shift of 100m. I guess it has to be something with the projection. Map: var options = { controls: [ new OpenLayers.Control.KeyboardDefaults(), new OpenLayers.Control.MouseDefaults(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher() ], maxExtent: new OpenLayers.Bounds( -20, -20, 20, 20), numZoomLevels: 19, units: 'm', projection: new OpenLayers.Projection(EPSG:900913), displayProjection: new OpenLayers.Projection(EPSG:4326), sphericalMercator: true }; map = new OpenLayers.Map(map, options); var binghybrid = new OpenLayers.Layer.VirtualEarth(Hybrid, { type: VEMapStyle.Hybrid }); KML: var animals = new OpenLayers.Layer.Vector(Animals, { projection: new OpenLayers.Projection(EPSG:4326), strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: kml/animals.kml, format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true }) }) }); Anybody?! ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] KML over VirtualEarth Map doesn't display or hasa shift
Hi, I think, you have add 'sphericalMercator' to your layer. var vehyb = new OpenLayers.Layer.VirtualEarth( Virtual Earth Hybrid, {'type': VEMapStyle.Hybrid, 'sphericalMercator': true} ); Arnd -Ursprüngliche Nachricht- Von: users-boun...@openlayers.org [mailto:users-boun...@openlayers.org] Im Auftrag von Stefan Keller Gesendet: Freitag, 30. April 2010 19:47 An: users@openlayers.org Betreff: [OpenLayers-Users] KML over VirtualEarth Map doesn't display or hasa shift Hi! I'm trying to lay an KML over VirtualEarth Map in OpenLayers, but it either does'nt display anything or KML points have a shift of 100m. I guess it has to be something with the projection. Map: var options = { controls: [ new OpenLayers.Control.KeyboardDefaults(), new OpenLayers.Control.MouseDefaults(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher() ], maxExtent: new OpenLayers.Bounds( -20, -20, 20, 20), numZoomLevels: 19, units: 'm', projection: new OpenLayers.Projection(EPSG:900913), displayProjection: new OpenLayers.Projection(EPSG:4326), sphericalMercator: true }; map = new OpenLayers.Map(map, options); var binghybrid = new OpenLayers.Layer.VirtualEarth(Hybrid, { type: VEMapStyle.Hybrid }); KML: var animals = new OpenLayers.Layer.Vector(Animals, { projection: new OpenLayers.Projection(EPSG:4326), strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: kml/animals.kml, format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true }) }) }); Anybody?! ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users
Re: [OpenLayers-Users] show only specific objects, wms
David, You can use Geoserver WMS vendor parameters for GetMap requests: http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters See how it is done in Geoserver Layer Preview page. Best regards, Gabriel Nolasco Hy all, I use GeoServer with OpenLayers. I have a WMS Layer with many kinds types of objects. How can I show only for example object whose attribut has a special value? I know I can create SLD so that it shows what I need. But the problem ist that I have about 1000 different attribut values. And I can't create 1000 SLD documents... I hope you understood my problem... Is this possible with a WMS Layer? Or is there a way I can change the SLD on runtime? cheers David ___ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users