Define your style variable like this:
var style = new OpenLayers.Style({ graphicHeight: "${size}", graphicWidth: "${size}" }, { context: { size: function() { return 60*18/map.getZoom(); } } } );
Le 20 juin 2012 à 15:01, christian bleau a écrit : Hi Olivier and Steve,
I try to follow your way but it din't work It's sure I have forgot something ...
http://pofableau.com/openlayer/multicouche.html
the overlay code is ok for depart and calque but without possibility to scaling with panZoom.
It's the pb exposed in the beginning of this topic.
the overlay départ2 who use your recommandation isn't visible on the map
I use this code :
var style = new OpenLayers.Style(
OpenLayers.Util.applyDefaults(
{fillColor: "green", fillOpacity: 1, strokeColor: "black"},
{
rules: [
new OpenLayers.Rule({
maxScaleDenominator: 200000000,
minScaleDenominator: 100000000,
symbolizer: {
externalGraphic: 'a_img/travauxorange.png',
graphicHeight: 60*18/10 ,
graphicWidth: 65*18/10
}
}),
new OpenLayers.Rule({
maxScaleDenominator: 100000000,
symbolizer: {
externalGraphic: 'a_img/travauxorange.png',
graphicHeight: 60*18/5,
graphicWidth: 65*18/5
}
})
]
}));
var depart = new OpenLayers.Layer.Vector("Depart", {
styleMap: new OpenLayers.StyleMap(style) });
map.addLayer(depart);
Steve I wrote the following code for depart and calque but there is no change for scale the Image as you can see. May be It's necessary to have a time out for the script ?
var z= map.getScale();
var graphicWidth = 55;
var graphicHeight = 50;
var scaleFactorWidth = graphicWidth * z;
var scaleFactorHeight = graphicHeight * z;
var depart2 = new OpenLayers.Layer.Vector("Départ2");
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(2.534000,48.387000).transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
),
{some:'data'},
{externalGraphic: 'a_img/travauxorange.png', graphicHeight: graphicHeight, graphicWidth: scaleFactorWidth});
depart2.addFeatures(feature);
Thank a lot for your help.
Christian
View this message in context: Re: pb with map.getZoom
Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
Olivier Terral
 GEOMATIC Ingénierie SA Société du groupe Ringier Chemin des Croisettes 26 1066 Epalinges www.geomatic.ch
|