[OpenLayers-Users] Multiple labels on the same polygon

Lehtonen, Mika mika at digikartta.net
Wed Oct 29 02:46:50 EDT 2008


No no,

the functionality of OL is quite adequate for me as it's now. Actually 
using SingleTile renders the labels almost exactly like I wanted them to 
render. What I was refering to was that using TILED:true doesn't work 
for me for some reason. With just polygon layer it works, but with 
Google map as a base map it stop working properly. Some of the tiles in 
the view don't get rendered at all. The outcome is bands with missing 
polygon/label layer in the edge of the view.

But never mind. SingleTile works just fine. My polygon/label layer is 
quite light.

Thanks anyway,
- mika -

Tim Schaub kirjoitti:
> Hey-
>
> Lehtonen, Mika wrote:
>   
>> Hi again Tim,
>>
>> obviously I have to move on to server side caching, but I decided to 
>> first try TILED: true parameter. The problem with that is that not all 
>> the tiles are rendered in the screen. And also the multiple label on 
>> single polygon problem persists with certain zoom levels. With Single 
>> Tile everything is working fine though I probably suffer of some 
>> performance lack, I guess.
>>
>>     
>
> Right, if you really want absolute control over label position, you 
> label points (or create label points for your polygons).
>
> If there were some option to only label polygon centroid, then you would 
> loose any label conflict detection/resolution.
>
> In general, the more control you want over the behavior, the more you 
> are going to have to maintain - and modify when you change your mind.
>
> This is getting pretty far from the functionality provided by OpenLayers.
>
> Tim
>
>   
>> - mika -
>>
>> Tim Schaub kirjoitti:
>>     
>>> Hey-
>>>
>>> Lehtonen, Mika wrote:
>>>  
>>>       
>>>> Hi,
>>>>
>>>> I am trying to do some labels on polygons which are in an overlay 
>>>> layer on top of Google Map base layer. The polygon data is served 
>>>> through WMS (Geoserver). Labels are produced in GeoServer using its 
>>>> own style definition (TextSymbolizer). The problem is that larger 
>>>> polygons get more than one label on them. I would prefer them to have 
>>>> exactly one per polygon. If I test the polygon layer with Geoserver's 
>>>> OL preview, everything is just like I would want it to be. But my 
>>>> html page is something else.
>>>>
>>>>     
>>>>         
>>> Regarding labels, your WMS layer probably uses multiple tiles (unless 
>>> you set singleTile to true).  With multiple tile requests, the server 
>>> treats each as independent, so it will faithfully label as many 
>>> polygons as the tile bounds intersect.
>>>
>>> A good solution for nicely labeled tiles that improves performance is 
>>> to use something that creates meta-tiles (big tiles that are sliced 
>>> into smaller ones) and caches your rendered tiles.  Both TileCache and 
>>> GeoWebCache will do this for you.
>>>
>>> If you have data that changes frequently - or some other reason not to 
>>> cache tiles on the server - you can use the non-standard TILED and 
>>> TILESORIGIN parameters in your WMS request.  This tells GeoServer that 
>>> multiple requests are coming in for tiles, and it figures out which 
>>> polygons to label.
>>>
>>> See these two examples:
>>>   http://tinyurl.com/tiledfalse (TILED=false)
>>>   http://tinyurl.com/tiledtrue (TILED=true)
>>>
>>> Read the bit on "On the fly meta tiler":
>>> http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters#WMSvendorparameters-TILED 
>>>
>>>
>>> Also, view the source of your GeoServer layer preview to see the use 
>>> in an OpenLayers page.
>>>
>>>  
>>>       
>>>> I also noticed that the scale in my page when compared to scale in 
>>>> the OL preview, is different. However, the SLD seem to be obeying the 
>>>> scale value although the real map scale is different. Could that 
>>>> differ be the key to my problems?
>>>>     
>>>>         
>>> OpenLayers assumes a display resolution of 72 dots per inch by 
>>> default.   This is almost always wrong (but an app designer has no way 
>>> of knowing).
>>>
>>> The SLD spec says the following:
>>>
>>> The "standardized rendering pixel size" is defined to be 0.28mm × 
>>> 0.28mm (millimeters).
>>>
>>> Which (as it admits) is frequently wrong (and generally unknown by the 
>>> server).  But, at least it is a standard.
>>>
>>> The GeoServer layer preview sets the OpenLayers.DOTS_PER_INCH constant 
>>> to match the SLD "standardized rendering pixel size."  You can do this 
>>> as well in your application:
>>>
>>> OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
>>>
>>>  
>>>       
>>>> I will deliver further information if needed. OL is either 2.7 or the 
>>>> one delivered with Geoserver 1.7.0.
>>>>
>>>>     
>>>>         
>>> None of the above will be different with any 2.x version of 
>>> OpenLayers.   But it looks like OpenLayers 2.7 got in to GeoServer 1.7 
>>> (http://jira.codehaus.org/browse/GEOS-2279).
>>>
>>> Good luck,
>>> Tim
>>>
>>>  
>>>       
>>>> - mika -
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>>     
>>>>         
>>>   
>>>       
>
>
>   



More information about the Users mailing list