2

I try to create a legend for the map separately in a different div.

How could I render a symbol (star e.g.) somewhere else in html, not only on the map with OpenLayers?

I guess I have to call OpenLayers.Renderer.symbol.star and display it elsewhere, but I couldn't figure out which method should be used...

The most perfect solution would be to get the exact styling properties like on the map... Is there a way for it?

  • Ok, there is a layer.renderer object, and there is a lot of possibilities in this objet to define die div id, but it still does not render in the new defined div. I think it is much more complicated than just to modify the size and the div on that way... – KriKox Oct 28 '15 at 16:47
1

If you are using a vector layer you could create a vector legend (http://api.geoext.org/1.0/examples/vector-legend.html ) . If you are using WMS-layer you can use a getlegend-request.

Edit1: here as jsfiddle about how to use OpenLayers.Renderer to create a static "map" as a legend. http://jsfiddle.net/expedio/g8LncceL/

| improve this answer | |
  • Thanks for the answer! Unfortunately the legend has to be fully customizable and the project is quite big to build in geoext at this stage. So I can't use this possability... I have the assumption that I have to create the symbols again with svg separately... – KriKox Oct 29 '15 at 12:10
  • yes, you can build them with SVG or the OpenLayers.renderer inside a static mal that acts as a legend. I have added a jsfiddle above. – Thomas B Oct 29 '15 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.