Hi,

You can do it by using context und template for your style:

var styleMapLabelZoom;

function set_styleMapLabelZoom()
{
    var context = {
        getFontSize : function(){
            var diffZ = map.getZoom() - 14;
            return diffZ > 0 ? 7 + 3*diffZ +"px" : "0px";
        },
        getName : function (ft){
            return ft.attributes.name;
        }
    };
    var template = {
        strokeColor: "#0000FF",
        strokeOpacity: 1,
        strokeWidth: 3,
        fillColor: "#00AAFF",
        fillOpacity: 1,
        pointRadius: 5,
        pointerEvents: "visiblePainted",

        label : "${getName}",

        labelOffsetX: "10",
        labelOffsetY: "-10",
        fontColor: "red",
        fontSize: "${getFontSize}",
        fontFamily: "Arial",
        fontWeight: "bold",
        labelAlign: "bt"
    };
    styleMapLabelZoom = new OpenLayers.StyleMap(new
OpenLayers.Style(template, {context:context}) );
}

set_styleMapLabelZoom();
yourLayer.styleMap=styleMapLabelZoom;
yourLayer.redraw();

http://gis.ibbeck.de/OLClient/OLClient.asp?WMC=./data/WMC/styleMapLabelZoom.
wmc.xml

Arnd
 

-----Ursprüngliche Nachricht-----
Von: maning sambale [mailto:[email protected]] 
Gesendet: Montag, 14. September 2009 04:27
An: Arnd Wippermann
Cc: [email protected]
Betreff: Re: [OpenLayers-Users] using openlayers as map
interfacefordownloading pdf maps

Follow-up question, is it possible to increase or decrease fontSize
depending on the zoom level.  At low zoom levels, the text seems crowded but
too small at higher zoom level.

On Fri, Sep 11, 2009 at 3:12 PM, maning sambale <[email protected]>
wrote:
> Arnd,
>
> Thanks! This worked without a hitch!
>
> On Thu, Sep 10, 2009 at 11:20 PM, Arnd Wippermann 
> <[email protected]> wrote:
>> Hi,
>>
>> Set extractStyles to false
>>
>> and add the following style to your layer after layer creation. It 
>> should also be possible to declare the style in the layer constructor.
>>
>> var styleMapLabel = new OpenLayers.StyleMap({'default':{
>>    strokeColor: "#00FF00",
>>    strokeOpacity: 1,
>>    strokeWidth: 3,
>>    fillColor: "#FF5500",
>>    fillOpacity: 0.5,
>>    pointRadius: 6,
>>    pointerEvents: "visiblePainted",
>>
>>    label : "${description}",
>>    //label : "name: ${name}, age: ${description}",
>>
>>    fontColor: "red",
>>    fontSize: "12px",
>>    fontFamily: "Arial",
>>    fontWeight: "bold",
>>    labelOffsetX: 10,
>>    labelOffsetY: 10
>>    //labelAlign: "${align}"
>> }});
>>
>> map.layers[1].styleMap = styleMapLabel; map.layers[1].redraw();
>>
>> Arnd
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [email protected] 
>> [mailto:[email protected]] Im Auftrag von maning sambale
>> Gesendet: Donnerstag, 10. September 2009 09:13
>> An: OpenLayers-Users
>> Betreff: Re: [OpenLayers-Users] using openlayers as map 
>> interfacefordownloading pdf maps
>>
>> Hi,
>>
>> In doing this webmap I have sample here:
>> http://forest2002.essc.org.ph/test_map/
>>
>> What I want next is to:
>> 1. show kml layer label in the map for each polygon (mapsheet name 
>> and
>> number) 2. highlight color for the selected feature, either this one:
>> http://openlayers.org/dev/examples/highlight-feature.html
>> or this
>> http://gis.ibbeck.de/ginfo/apps/planwerk/planwerk_nordbahntrasse.asp
>>
>> Any advise?
>>
>>
>>
>> On Thu, Sep 10, 2009 at 12:08 AM, Arnd Wippermann 
>> <[email protected]>
>> wrote:
>>> Hi,
>>>
>>> Have a look at
>>> http://gis.ibbeck.de/ginfo/apps/planwerk/planwerk_nordbahntrasse.asp.
>>>
>>> A click on a feature generates a link above the map for download of a
pdf.
>>>
>>> Arnd
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: [email protected]
>>> [mailto:[email protected]] Im Auftrag von maning sambale
>>> Gesendet: Mittwoch, 9. September 2009 12:41
>>> An: OpenLayers-Users
>>> Betreff: [OpenLayers-Users] using openlayers as map interface 
>>> fordownloading pdf maps
>>>
>>> Hi,
>>>
>>> We have prepared 1:250k sacle pdf topo maps for download.  I want to 
>>> use openlayers as an interface for downloading.  The plan is to show 
>>> the map boundingbox as a kml layer or georss over a slippymapy.  
>>> Each box would provide a link to the pdf download.  Any sample I can
work with.
>>>
>>> Thanks in advance.
>>> --
>>> cheers,
>>> maning
>>> ------------------------------------------------------
>>> "Freedom is still the most radical idea of all" -N.Branden
>>> wiki: http://esambale.wikispaces.com/
>>> blog: http://epsg4253.wordpress.com/
>>> ------------------------------------------------------
>>> _______________________________________________
>>> Users mailing list
>>> [email protected]
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>
>>
>>
>> --
>> cheers,
>> maning
>> ------------------------------------------------------
>> "Freedom is still the most radical idea of all" -N.Branden
>> wiki: http://esambale.wikispaces.com/
>> blog: http://epsg4253.wordpress.com/
>> ------------------------------------------------------
>> _______________________________________________
>> Users mailing list
>> [email protected]
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
>
>
> --
> cheers,
> maning
> ------------------------------------------------------
> "Freedom is still the most radical idea of all" -N.Branden
> wiki: http://esambale.wikispaces.com/
> blog: http://epsg4253.wordpress.com/
> ------------------------------------------------------
>



--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to