[OpenLayers-Users] BBOX Strategy and StyleMap problem

Arnd Wippermann arnd.wippermann at web.de
Mon Dec 3 13:02:11 PST 2012


Hi Mario,

I don't no why, but for the KML-Layer the
propertyStyles:{externalGraphic:true} have to be set.
For the Text-Layer it isn't needed.

I have updated my example to show the difference between the two formats.

Regard,
Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Mario
Danelli
Gesendet: Samstag, 1. Dezember 2012 22:12
An: openlayers-users at lists.osgeo.org
Betreff: Re: [OpenLayers-Users] BBOX Strategy and StyleMap problem

Dear Arnd,

it should but it doesn't work.
I don't know why...

I implemented a work-around with an ajax call into the moveend event linked
to the map

eventListeners: {
    "moveend": mapEventMove,
}

In "done" ajax case i parsed the text results and used the removeAllFeatures
and addFeatures.

Thanks

Mario Danelli


Il 01/12/2012 16:58, Arnd Wippermann ha scritto:
> Your problem should be solved with a styleMap like this
>
> styleMap: new OpenLayers.StyleMap({
>              "default": new OpenLayers.Style({
>                  externalGraphic: "kml_csv_data_layer_marker-${Type}.png",
>                  graphicWidth: 21,
>                  graphicHeight: 25,
>                  graphicXOffset: -11,
>                  graphicYOffset: -25
>          })
> })
>
> Example:
> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL212/kml_csv_data_layer/km
> l_csv_
> data_layer.asp?propertyStyles=true
>
> Regards,
> Arnd
> gis.ibbeck.de
>
> -----Ursprüngliche Nachricht-----
> Von: openlayers-users-bounces at lists.osgeo.org
> [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Mario 
> Danelli
> Gesendet: Samstag, 1. Dezember 2012 06:42
> An: openlayers-users at lists.osgeo.org
> Betreff: [OpenLayers-Users] BBOX Strategy and StyleMap problem
>
> Dear all,
>
> I've a problem trying to apply a custom (different marker pngs 
> following a specific type) markers when using BBOX Strategy to get
features data.
> I'm using Openlayers 2.12.
>
> Below the code
>
>
> var pois = new OpenLayers.Layer.Vector("POIs", {
> 			        projection: new
> OpenLayers.Projection("EPSG:4326"),
> 					strategies: [new
> OpenLayers.Strategy.BBOX({resFactor: 1.1})],
> 			     	protocol: new OpenLayers.Protocol.HTTP({
> 						url: "./get_data.php",
> 			            format: new OpenLayers.Format.Text()
> 			        }),
> 			        styleMap: new OpenLayers.StyleMap({
> 								"default": {
> 	
> externalGraphic: "./js/openlayers/img/marker-${type}.png",
> 	
> graphicHeight: 20,
> 	
> name: "${id}",
> 									id:
> "${type}" + "-" + "${id}"
> 							}
> 					})
>
> map.addLayer(pois);
> pois.setVisibility(true);
> 				
> pois.events.on({
> 	    'featureselected': onFeatureSelect,
> 	    'featureunselected': onFeatureUnselect
> 	});
>
> selectControl = new OpenLayers.Control.SelectFeature(pois);
>
> map.addControl(selectControl);
> selectControl.activate();
>
>
> the "get_data.php" returns data as example below
>
> id	point	ref_lat	ref_lon	name	descr	type
> 2	55.92,14.3	55.92	14.3	Name1	descr1	t1
> 3	56.1,10.2	56.16	10.2	Name2	descr2	t2
> 4	56.13,10.21	56.13	10.21	Name3	descr3	t1
>
>
> The goal is to have different markers (colours) if the points are of 
> type "t1" or "t2". But it's nevere selected the correct marker (for
> example: marker-t1.png) but every time is selected the default marker.png.
> The behaviour is the same if I specificy a "not parameterized" marker 
> (for example externalGraphic: "./js/openlayers/img/marker-ABC.png").
>
> What's wrong?
>
> Anyone can help me?
>
> Thanks
>
> Mario Danelli
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>


_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list