Identifying marker clicked in EventListener's JS function

65 views
Skip to first unread message

vision

unread,
Jul 11, 2009, 10:16:24 PM7/11/09
to gmaps4jsf-dev
So I've created a map with a variable amount of markers using
ui:repeat, each having an event listener. However, I have yet to
figure out a way to identify which marker was clicked (more than just
it's latitude/longitude coordinates). I've tried doing it explicitly
like below, overwriting the MarkerValue that I believe is passed, but
this causes the js function to be executed on page load. Is there a
currently a way to do what I'm attempting in my example below?


<m:map latitude="#{gmap.latitude}" longitude="#{gmap.longitude}"
type="G_NORMAL_MAP">
<ui:repeat var="m" value="#{gmap.markers}">
<m:marker latitude="#{m.latitude}" longitude="#{m.longitude}">
<m:eventListener eventName="click" jsFunction="markerClickHandler
('#{m.title}')"/>
</m:marker>
</ui:repeat>
</m:map>

<script type="text/javascript">
function markerClickHandler(title) {
alert("Title is " + title);
}
</script>

Thanks,
.Robert

Hazem Saleh

unread,
Jul 12, 2009, 3:44:04 AM7/12/09
to gmaps4...@googlegroups.com
How the JS function executed on page load, you mean it is executed on page load not on marker click?

vision

unread,
Jul 17, 2009, 10:16:44 PM7/17/09
to gmaps4jsf-dev
Sorry, I didn't see this reply. I haven't used google groups before
and expected to get an email about a reply... Anways, yes, it's ran
on page load, which should have been quite obvious to me before. What
it's actually doing is making the function call when the page is
loaded, and trying to use whatever value the function returns as the
jsFunction name.

I have since been looking at the documentation of google maps more
closely and understand better it's use of closures and anonymous
functions to pass information. I haven't yet tried translating this
or my other ideas on how to get it working with gmaps4jsf. Perhaps
something I can play around with this weekend.

.robert
> Author of (The Definitive Guide to Apache MyFaces and Facelets):http://www.amazon.com/Definitive-Guide-Apache-MyFaces-Facelets/dp/159...
>
> Web blog:http://www.jroller.com/page/HazemBlog
>
> [Web 2.0] Google Maps Integration with JSF:http://code.google.com/p/gmaps4jsf/http://www.theserverside.com/tt/articles/article.tss?l=Introductionto...

Claudio Margulhano

unread,
Jun 14, 2013, 1:28:13 PM6/14/13
to gmaps4...@googlegroups.com, broke...@gmail.com
how do I solve this?
Reply all
Reply to author
Forward
0 new messages