[OpenLayers-Users] pb with map.getZoom
Olivier Terral
olivier at geomatic.ch
Wed Jun 20 09:10:35 PDT 2012
Define your style variable like this:
var style = new OpenLayers.Style({
externalGraphic: 'http://pofableau.com/openlayer/a_img/travauxorange.png',
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
> Users at lists.osgeo.org
> 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
www.thevirtualcity.ch
Tél:: +41 (21) 651 30 00
Fax: +41 (21) 651 30 09
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120620/bd4e62ec/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.gif
Type: image/gif
Size: 5116 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120620/bd4e62ec/attachment-0001.gif>
More information about the Users
mailing list