[OpenLayers-Users] marker using a on-the-fly created icon

Steve Nelson snelson at webapper.com
Sun Apr 22 00:06:51 EDT 2012


Sure this can be done. Use vectors, not markers. Markers are deprecated and
will drive you nuts with bugs.

With vectors you create a "style" and set the externalGraphic to the URL of
the image you want. Something like this (this is totally untested, so mess
around with it):

style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
style.externalGraphic="http://domain.com/yourimage.png"
style.graphicWidth=62
style.graphicHeight=38

vectorPoint=new OpenLayers.Geometry.Point(-76.269, 36.8741);

vector = new OpenLayers.Feature.Vector(vectorPoint,null,style);

vectorLayer.addFeatures([vector]);


Anyway, that's the vector part, the canvas part may be a little trickier,
because you need to ultimately create a URL.

Maybe what you could do is base64 the canvas image, then use that as your
url. Or if you use html5 file writer, you could write it locally in the
browser. You've probably already seen this, but you can base64 the image
and use it like a url, like this:

<img src="data:image/png;*base64*,iVBORw0KGgoAAAANSiVBORw0KGgoAAAANS">

Did that help?

Steve

On Sat, Apr 21, 2012 at 11:28 PM, alexe100 <imoveisnacionais at gmail.com>wrote:

> Hi
> I would like to set an icon to a marker with specific information, for
> example the veicle plate and not the same icon for all the markers.
>
> Is it possible to create an icon on the fly using a canvas or something and
> set that icon or image to a specific marker?
>
> Like this: imagine a map with 10 markers (veicles). All the markers are
> resoresented by the same global image/icon but bellow the icon or image
> there is allways present the veicle plate.
>
>
>
> Thanks a lot
>
>
> Alex
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/marker-using-a-on-the-fly-created-icon-tp4906613p4906613.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120422/cf0df0d2/attachment-0001.html


More information about the Users mailing list