-
1. Re: getting a point in rich:gmap?
sergeysmirnov Apr 22, 2007 12:23 PM (in response to okr2004)not like this. onclick on the component just gives the fact that you click on the whole object.
To work with gmap you have to use the standard Google API. Those are most useful links.
http://www.google.com/apis/maps/documentation/
http://www.econym.demon.co.uk/googlemaps/
rich:gmap has gmapVar attribute. The javascript variable that is used to access the Google Map API. If you have more than one Google Map components on the same page, use individual key for each of them. The default variable name is "map" (without quotes)
Important: Google Map is initialize only after page is loaded. So, initiate your listeners from -
2. Re: getting a point in rich:gmap?
okr2004 Apr 22, 2007 2:39 PM (in response to okr2004)Thanks for your advice.
After registering an event listener, it works fine.
Now i only have to find a good place to initiate the listener... :-) -
3. Re: getting a point in rich:gmap?
sergeysmirnov Apr 22, 2007 5:13 PM (in response to okr2004)let me know when you found it
-
4. Re: getting a point in rich:gmap?
sergeysmirnov Apr 23, 2007 1:47 PM (in response to okr2004)If not, I can show you a couple of ways
-
5. Re: getting a point in rich:gmap?
okr2004 Apr 24, 2007 1:38 AM (in response to okr2004)I havn't found a good place yet. So you can show me some ways...
-
6. Re: getting a point in rich:gmap?
sergeysmirnov Apr 24, 2007 6:04 PM (in response to okr2004)I just have added 'oninit' attribute to rich:gmap . So, the way will be much simpler. This attribute will be available since the next nightly build.
For previous version of richfaces, you can add one more code onload with prototype.js:
Event.observe(window, "load", func );
Ajax4jsf is shipped with Prototype.js. So, you can use it in your code. To make it available of the page, add the following code:<a4j:loadScript src="resource://prototype.js" />
Then, you can define:.... function myInitFunc() { // your init code for gmap } .... Event.observe(window, "load", myInitFunc ); ....
-
7. Re: getting a point in rich:gmap?
okr2004 Apr 25, 2007 1:54 PM (in response to okr2004)thanks for your help and the 'oninit'-attribute. Now it works and will try 'oninit' in the next release of richfaces.
-
8. Re: getting a point in rich:gmap?
v.bannur Mar 10, 2011 3:00 AM (in response to okr2004)Here is the code to get the point on click of google map
<rich:gmap id="gm" lat="#{bean.lat}" lng="#{bean.lng}" zoom="#{bean.zoom}" gmapVar="map" locale="EN"
gmapKey="ABQIAAAAxU6W9QEhFLMNdc3ATIu-VxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRkrpOGzxH8_ud3inE9pG1845-FCA"
style="width:500px;height:400px" onclick="point(map);"/>
<a4j:outputPanel>
<script>
function place(map){
alert("Lat,Lng="+map.getBounds().getNorthEast());
alert("Lat="+map.getBounds().getNorthEast().lat());
alert("Lng="+map.getBounds().getNorthEast().lng());
var point = new GLatLng(lat, lng);
}
</script>
</a4j:outputPanel>