[OpenLayers-Users] Using external/inline SVG for a map feature

Harris Hudson hhudson at katmandu.org
Tue Nov 27 18:08:26 PST 2012


For modern browsers, to add a fixed size external static SVG as a feature
you can specify your SVG using externalGraphic.  This will work for static
SVG because it will add the SVG to the map based on the <img> tag.  This
approach wont work fully if your SVG is interactive or has external styling.

The InlineXhtml Addin can be used to add interactive or externally styled
SVG to the map as map layers - ie layers that pan and scale with the map.
Currently, I don't believe there is a way to add a fixed size, interactive
or externally styled, SVG image at an arbitrary map location.

I think your initial investigations are right - this would require either
extending the InlineXhtml capabilities or taking components of InlineXhtml
and combining them with the way features can be added.

Regards,

Harris.


> I did, however I see that there is a tile and layer implementation, but I
> am looking for just a feature, not something that is always shown as a
> single layer. Plus, these features will be dynamically added and there may
> be several features on a single layer.
>
> My use case is this: There is a service that generates SVG graphics based
> upon various input locations (1 to many points). The returned graphic may
> contain some complex SVG. Therefore, I must be able to support adding
> these to the layer dynamically and at various locations, (while supporting
> panning and zooming, of course).
>
> My initial plan was to take the InlineXhtml code and try to make it work
> for features, but it looked like a hefty task (looking into how the SVG
> renderer drew the features and "generated" SVG didn't seem to have much
> flexibility if I wanted to use my own SVG inline with a feature), so I
> figured I'd ask to see if there was an easier way first.
>
> Matt Wintercorn
> matt at stackframe.com
>
>
>
> On Nov 27, 2012, at 10:53 AM, Bart van den Eijnden <bartvde at opengeo.org>
> wrote:
>
>> Did you look into:
>>
>> http://trac.osgeo.org/openlayers/wiki/Addins/InlineXhtml
>>
>> already?
>>
>> Best regards,
>> Bart
>>
>> --
>> Bart van den Eijnden
>> OpenGeo - http://opengeo.org
>> Expert service straight from the developers.
>>
>>
>>
>> On Nov 27, 2012, at 9:26 AM, Matt Wintercorn <matt at stackframe.com>
>> wrote:
>>
>>> Is it possible to use an external SVG definition as the source for a
>>> feature graphic in OpenLayers. My SVG already has the necessary <g>
>>> tags with all of the <path> elements containing my graphic. The only
>>> thing that I am seeing is that OpenLayers really only supports drawing
>>> points, lines, rectangles, and simple polygons by taking a list of
>>> points and "generating" an SVG. What can I do if I just want to use my
>>> existing SVG definition??? (I am using the SVG renderer and would like
>>> to take advantage of the built in SVG transforms to correctly scale and
>>> position my SVG element on the map)
>>>
>>>
>>> Matt Wintercorn
>>> matt at stackframe.com
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>




More information about the Users mailing list