tags:

views:

598

answers:

2
A: 

For example:

<rich:gmap var="mapVar" ... />

and then (in a javascript block, below the definition of <rich:gmap>)

window.onload = function() {
    mapVar.addOverlay(
        new GMarker(new GLatLng(#{yourBean.lat}, #{yourBean.lng})));
}

You should take a look at the Google maps API for all possible ways of loading your map.

Bozho
ok but where exactly do I type in this mapVar.addOverlay? I know it is noobish question but I am new on this field.... :(
ortho
@ortho see my update. Especially when you are new, I'd advice some thorough reading through the documentation of the technology you are using.
Bozho
could you look at the example below please?
ortho
@ortho - SO is not a forum. update your question rather than posting an answer. As for your update - GMarker requires a GLatLng argument - instnatiate such (as shown in my update)
Bozho
@bozho sorry for that, now it is updated. I ve added the source code of this component called map.jsp (I have two versions, another is: map.xhtml). I can make the programatic version (pure javascript) now, but then I have an issue with templating in main file. In this case i would rather make it work in this rich:gmap component. The issue is that window class doesn't contain "onload" method and when I type the name of map (here mapVar), then it doesn't find it either. I feel like I miss something obvious but I can't find what it is, please help.
ortho
@ortho at first sight you have an additional `window.` line which you should remove. What does your js console (firefox) say?
Bozho
@bozho Thank you for your help so far. I managed that to work in xhtml via only <script> block where I define a new map from the very beginning. I am using eclipse and this is the project with java EE + tomcat server + jsf and richfaces (a4j as AJAX included). I did not want to use any pure javascript at all, but now I ended up with only js :) . I still don't know why I cannot refer to <rich:gmap /> component. It seems that neither AJAX nor pure JS see it. In flex you can easily refer to and then modify the mxml components via action script... I wish it could be easier :P
ortho
I recall google maps had problems with xhtml. Try html.
Bozho
A: 

Deleted due to update

ortho