[OpenLayers-Users] How to draw a arrow with openlayer?

Pierre Giraud pierre.giraud at camptocamp.com
Thu Aug 1 07:34:38 PDT 2013


Hi all,

I was looking for such a feature (ie. drawing arrows along line to
show direction) and looked at the several examples proposed.
I chose a different approach though. I tried to be less intrusive and
do the job in the renderer instead of adding layers or features. My
main goal was to avoid having features polutting an editing layer.

Extending the renderers to display new elements seemed easy.

Here's the result: http://bl.ocks.org/pgiraud/6131715

I didn't think about any side effects but would be happy to hear cases
where it could fail.

What do you think?

Pierre

On Tue, Jan 29, 2013 at 2:14 PM, Alexandre Dubé <adube at mapgears.com> wrote:
> Hi Hua Jie,
>
>   What you did is really nice!  You could contribute this by making an
> example out of it :
>
>   * fork openlayers 'master' branch and clone
>   * create new .html and .js in the 'examples' directory to create an
> example out of it, using the same files the other examples do.
>   * add/commit/push/pull request
>
>   Even though the class you created wouldn't be part of the actual core, it
> would still demonstrate how to assemble OpenLayers core components to
> achieve this.
>
> Regards,
>
> Alexandre
>
>
>
> On 13-01-28 10:46 PM, 杨华杰 wrote:
>
> Hi All
>
> Thanks for all the help.
>
> I draft a version first. Not sure how to contribute to the lib.
>
> Here is some screenshot.
> http://www.javalinux.me/?p=681
>
>
> Here is the demo page:
> http://www.javalinux.me/openlayer/arrow/
>
>
> Regards,
> Hua Jie
>
>
> On Fri, Jan 25, 2013 at 6:25 PM, Arnd Wippermann <arnd.wippermann at web.de>
> wrote:
>>
>> Hi,
>>
>> may be this examples can help:
>>
>> approach like Imran described
>>
>> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL210/Line_Direction/direction_arrow.asp
>>
>>
>> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL212/Direction_Vectors/rotation_of_simple_direction_vectors.asp
>>
>>
>> Arnd
>>
>> ________________________________
>> Von: openlayers-users-bounces at lists.osgeo.org
>> [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von ???
>> Gesendet: Freitag, 25. Januar 2013 05:06
>> An: Imran Rajjad
>> Cc: openlayers-users at lists.osgeo.org
>> Betreff: Re: [OpenLayers-Users] How to draw a arrow with openlayer?
>>
>> Hi Guys
>>
>> I got some process.
>>
>> But I have a problem to draw with the mouse, during the drawing, I can see
>> the angle. But when I double click, the angle gone. Any tips will help.
>>
>>
>> Regards,
>> Hua Jie
>>
>>
>> On Thu, Jan 24, 2013 at 10:01 AM, 杨华杰 <yhjhoo at gmail.com> wrote:
>>>
>>> Hi Imran
>>>
>>> Thanks for your reply. I believe a lot people have the same questions.
>>> Why this feature is not released.
>>>
>>>
>>> Regards,
>>> Hua Jie
>>>
>>>
>>> On Wed, Jan 23, 2013 at 10:28 PM, Imran Rajjad <rajjad at gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> you can make a feature whose geometry is a GeometryCollection, this
>>>> collection can contain a line and a point grouped into one geometry then you
>>>> can use the below mentioned style to draw an arrow with your line
>>>>
>>>>
>>>> {
>>>> strokeColor: "#00688B",
>>>>     fillColor: "#00688B",
>>>>     fillOpacity : 1.0,
>>>>     strokeWidth: 2,
>>>>     strokeOpacity : 0.9,
>>>>     pointRadius: 6,
>>>>     graphicName :"triangle",
>>>>     rotation :angle
>>>> }
>>>>
>>>> remember to compute the angle before setting this .. you should be able
>>>> to calculate angle between start and end point of your line segment.. and
>>>> also the position of point geometry which will be drawn as triage with given
>>>> rotation angle..
>>>>
>>>> Hope I got my point through..
>>>>
>>>> regards,
>>>> Imran
>>>>
>>>> On Wed, Jan 23, 2013 at 7:11 PM, 杨华杰 <yhjhoo at gmail.com> wrote:
>>>>>
>>>>> Hi Alexandre
>>>>>
>>>>> Thank you, I will try this.
>>>>>
>>>>>
>>>>> Regards,
>>>>> Hua Jie
>>>>>
>>>>>
>>>>> On Wed, Jan 23, 2013 at 10:01 PM, Alexandre Dubé <adube at mapgears.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Hua Jie,
>>>>>>
>>>>>> You could try to define your own arrow symbol.  There's one defined
>>>>>> [here], see line 1 :
>>>>>>   OpenLayers.Renderer.symbol.arrow = [0,2, 1,0, 2,2, 1,0, 0,2]
>>>>>>
>>>>>>    I haven't tried it, but it could do the trick.
>>>>>>
>>>>>> HTH,
>>>>>>
>>>>>> Alexandre
>>>>>>
>>>>>> [here]
>>>>>> http://code.google.com/p/rep-olnet/source/browse/trunk/Direction.js?r=61
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 13-01-23 07:09 AM, 杨华杰 wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> As the title
>>>>>>
>>>>>> I know how to draw a line, dot, polygon. But my customer need some
>>>>>> directions on the map
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Hua Jie
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Users mailing list
>>>>>> Users at lists.osgeo.org
>>>>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Alexandre Dubé
>>>>>> Mapgears
>>>>>> www.mapgears.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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> I.R
>>>
>>>
>>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Pierre GIRAUD
Géomaticien, Analyste

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 93
Mail : pierre.giraud at camptocamp.com
http://www.camptocamp.com


More information about the Users mailing list