[OpenLayers-Users] How to replace country color with image ?

David Fawcett david.fawcett at gmail.com
Tue Sep 1 09:57:20 EDT 2009


Jerome,

I don't know anything about your application and the infrastructure
that you are running it on.  If you are using MapServer to serve WMS
or WFS layers to your OpenLayers app, I have a different approach that
could work for you.

Instead of using an OpenLayers vector layer, you could use a WMS
layer, where the styling is done on the server.  MapServer can use an
image to color the fill of a polygon.

There are examples here (near the bottom of the document):
http://mapserver.org/mapfile/symbology/construction.html?highlight=symbols

David.

On Tue, Sep 1, 2009 at 1:06 AM, Jerome Freyre<jerome.freyre at hispeed.ch> wrote:
> Hi Jan,
> I search for a solution but without success... I tried some scripts but it
> was the same result... nothing!
> I think it is not possible to define a background picture for a polygon but
> only for features like points...
> And unfortunately, I have no other options for now ...
> Best regards,
> Jérome
>
> Le 31 août 09 à 14:37, Jan.Sørensen (via Nabble) a écrit :
>
> Hi Jerome,
>
> Thanks for the reply.
> I tried using the externalGraphic, but without much success.
> The code is as follows:
>
> var stylemap = new OpenLayers.StyleMap({externalGraphic:
> '/images/country.jpg'});
>
> in my _buildStyle function where I define theme and rules respectively.
>
> The problem is that when I define colors for onSelect event its ok:
>
> var stylemap = new OpenLayers.StyleMap({'default':theme, 'select':
> {'strokeColor': '#59bce6', 'fillColor': '#59bce6', 'strokeWidth': 1}});
>
> I read this sample: http://docs.openlayers.org/library/feature_styling.html
> and the only difference is that I am using GML instead of vectors.
>
> Could that be the problem ?
>
> Cheers,
> js
>
> Jerome Freyre wrote:
> Hi Jan,
>
> maybe you can use the property
>
> externalGraphic : myStaticImage
>
> in the style definition
>
> Sincerly,
> Jérome
>
>
> Jan.Sørensen wrote:
> Hi,
>
> I'm pretty new to Open Layers, so probably I'm looking for something obvious
> :)
>
> I want to fill country with instead of a color with a static image
> Up to now I have a default style that upon mouse over I successfully changes
> color of the country that mouse cursor is currently on.
>
> Anyone can give me a shot ?
>
> Cheers,
> JS
>
>
> ________________________________
> View this message in context: Re: [OpenLayers-Users] How to replace country
> color with image ?
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



More information about the Users mailing list