[OpenLayers-Users] pb with map.getZoom
Christian Bleau
christian.bleau at gmail.com
Thu Jun 21 05:01:25 PDT 2012
Hi the pb is solved with this code.
variables map.getScale ( ); or getZoom send a good information if it's inside a function .....
style = new OpenLayers.Style({
externalGraphic: 'http://pofableau.com/openlayer/calque.png',
graphicHeight: "${H1}",
graphicWidth: "${W1}"
},
{ context: {
H1: function() { return 272/map.getScale()*2000;},
W1: function() { return 200/map.getScale()*2000;}
} }
);
var couche_calque = new OpenLayers.Layer.Vector("Calque", {
styleMap: new OpenLayers.StyleMap(style) }
);
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(2.534904,48.387375).transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
),
{some:'data'}
);
couche_calque.addFeatures(feature);
http://pofableau.com/openlayer/multicouche.html
Many thanks for the help.
Christian
Le 19 juin 2012 à 16:52, Olivier Terral a écrit :
> Hi Christian,
>
> You're doing a getZoom() just after created the map and before a zooming function, so the zoom property of the map is logically 0.
>
> Anyway, I think you use a wrong way of managing scale dependent size.
>
> Your problem seems similar to this example: http://dev.openlayers.org/releases/OpenLayers-2.11/examples/label-scale.html .
>
> Hope this helps.
>
> Tschuuss
>
> Le 19 juin 2012 à 15:05, christian bleau a écrit :
>
>> Hi, i'm just trying to use OL and I meet a problem with map.getZoom here's url of my test. for adapt an size of an OpenLayers.Layer.Vector and an externalGraphic I call a var zoom with map.getZoom line: 159 I call var z= map.getZoom(); for change the size of an image But they don't work "Error: Invalid value for attribute height="Infinity" If I try to see the z'value Firebug give me "0" ..... Thank a lot if you have the solution I search it since two days.
>> View this message in context: 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
>
> <PastedGraphic-1.gif>
>
> 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
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
Christian
Pof at Bleau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120621/2cebaf60/attachment.html>
More information about the Users
mailing list