[OpenLayers-Users] OpenLayers feature labeling - not working anymore

3Deography.net info at 3deography.net
Sat Oct 24 05:19:43 EDT 2009


Finally i solved the problem. As I assumed, the JSP engine caused the
problem. Expressions within JSP are initiated with the "$" symbol and
because of that, the compiler wants to resolve the expression
${label_field}. This expression cannot be resolved (of course....) and the
expression returns nothing. So the solution, as you can imagine, is to
escape the "$" symbol.

So change the folowing bold line to label: "\${style_type}",

var style_types = {
  "gazetteer": {
    labelAlign: 'lb',
    label: "${style_type}",
    fontSize: "10px",
    fontColor: 'white',
    pointRadius: 3
  }
}

I this little (noob) info prevents other users from googeling a lot ;-)

Bye,
Martin


3Deography.net wrote:
> 
> I spent a looooot of time, searching this needle in the haystack :-(
> 
> I tried to get this example running (again):
> http://openlayers.org/dev/examples/vector-features-with-text.html
> 
> Works fine on my Tomcat6 - but the strange behaviour is: If I rename the
> test.html to test.jsp and insert <% out.println("Hello World"); %>, it
> doesn't work anymore. Any ideas?
> 
> 
> 3Deography.net wrote:
>> 
>> Hi,
>> 
>> I just migrated from apache/mysql to tomcat/postgresql and everything's
>> working fine - except 1 thing:
>> 
>> I use custom style types to visualize spatial db-data and want to label
>> features on a vector layer. The label can be found within the features
>> attributes. But this won't work anymore. Any ideas?
>> The styleMap itself works because if I use a static string, it affects
>> the right features/layer and labels them. The attribute "style_map"
>> exists as the unique values for styling are switched, based on this
>> field. If i try, "title"... nothing changes.
>> 
>> Somehow, the labelling ${attribute_fiels} won't work. Any help would be
>> appreciated as I am stuck right now :-(
>> 
>> 
>> var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults({
>>   fillOpacity: 0.7,
>>   strokeColor: "black"},
>>   OpenLayers.Feature.Vector.style["default"])
>> );
>> 
>> var style_types = {
>>   "gazetteer": {
>>     labelAlign: 'lb',
>>     label: "${style_type}",
>>     fontSize: "10px",
>>     fontColor: 'white',
>>     pointRadius: 3
>>   }
>> }
>> 
>> styleMap.addUniqueValueRules("default", "style_type", style_types);
>> 
>> And here how the sample feature is passed by:
>> 
>> ...{ "type":
>> "Feature","properties":"title":"Germany","featureType":"country","style_type":"gazetteer","tooltip":"wiki"},...
>> 
>> The fields title and style_type definitely exist and contain values ;-)
>> 
>> Regards,
>> Martin
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/OpenLayers-feature-labeling-not-working-anymore-tp3871085p3883369.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list