[OpenLayers-Users] mouseover event creation for looped marker creation

Andrew Schuh andys at neptuneinc.org
Thu Oct 2 09:45:10 EDT 2008


I think what I was looking for was a "feature", still getting used to what
openlayers does a bit.  I will keep this response around to try next though
as I anticipate needing this kind of thing in the future.  Appreciate it.



Eric Lemoine-3 wrote:
> 
> On Tue, Sep 30, 2008 at 7:47 PM, Andrew Schuh <andys at neptuneinc.org>
> wrote:
>>
>> I have a question regarding event handling.  I'm new to this and I'm
>> having a
>> bit of trouble.  I'm looping over marker creation and I have a vector of
>> data that is updated on each iteration of loop (tmpmarks array with 4
>> members).  This works fine for the marker creation and placement but I
>> would
>> like to add information to be placed within a div tag on the web page
>> based
>> on mouseover.  It seems that the mouseover event is not statically
>> created
>> at the time it is defined and when it is called it always pulls the last
>> value of tmpmarks for all markers.  I'm sure this is just my lack of
>> understanding about event handling but could anybody give me advice on
>> how
>> to get around this?   Thanks in advance for any advice.
>>
>> ......
>> var marktmp = new OpenLayers.Marker(new
>> OpenLayers.LonLat(tmpmarks[0],tmpmarks[1]),iconblue.clone())
>> marktmp.events.register('mouseover',marktmp,function(evt)
>>
>> {filldiv('clustersizediv',tmpmarks[2]);filldiv('samplediv',tmpmarks[3]);
>> });
>> marktmp.events.register('mouseout',marktmp,function(evt)
>>
>> {blankdiv('clustersizediv');blankdiv('samplediv');OpenLayers.Event.stop(evt);
>> });
>> markers.addMarker(marktmp);}
> 
> Try (untested):
> 
> var marktmp = new OpenLayers.Marker(new
>     OpenLayers.LonLat(tmpmarks[0], tmpmarks[1]), iconblue.clone());
> 
> marktmp.events.register('mouseover', marktmp,
>     OpenLayers.Function.bind(function(evt) {
>         filldiv('clustersizediv', this.clustersizediv);
>         filldiv('samplediv', this.samplediv);
>      },  {clustersizediv: tmpmarks[2], samplediv: tmpmarks[3]})
> );
> 
> --
> Eric
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/mouseover-event-creation-for-looped-marker-creation-tp19747097p19779566.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list