[OpenLayers-Users] BBOX Strategy and StyleMap problem
Mario Danelli
mario.danelli at gmail.com
Fri Nov 30 21:42:01 PST 2012
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
More information about the Users
mailing list