|
HowToUseTheLibrary
How to configure the library:
<%@ taglib uri="http://code.google.com/p/gmaps4jsf/" prefix="m" %> and NEVER forget to include the Google maps script include in your page HEAD tag like:<script src="http://maps.google.com/maps?file=api&v=2& key=ABQIAAAAxrVS1QxlpJHXxQ2Vxg2bJBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxS9AOPy_YJl48ifAy4mq6I8SgK8fg" type="text/javascript"> </script>
Example of usages:
<m:map width="500px" height="500px" latitude="30.01" longitude="31.14" /> This will create a simple map of height = 500px and width = 500px, and the map will point to latitude = 30.01 and longitude = 31.41.
<m:map width="500px" height="500px" latitude="30.01" longitude="31.14">
<m:marker latitude="30.01" longitude="31.14"/>
<m:htmlInformationWindow latitude="30.01" longitude="31.14"
htmlText="<B>Egypt</B>"/>
</m:map>This will add a marker and an HTML information window to your map at latitude = 30.01 and longitude = 31.41, and the HTML information window will display the value in the (htmlText) attribute.
<m:map address="#{addressBean.address}">
<m:marker/>
<m:htmlInformationWindow htmlText="#{addressBean.address}"/>
</m:map>This will create a simple map that will point to the specific address with the marker and an information window containing the address.
<m:map width="500px" height="500px" latitude="30.01" longitude="31.14">
<m:mapControl name="GLargeMapControl" position="G_ANCHOR_BOTTOM_RIGHT"/>
<m:mapControl name="GMapTypeControl"/>
</m:map>This will add two controls on the map. The first control is the (GLargeMapControl) -its position will be in the bottom right of the map- , and the second control is the (GMapTypeControl) which enables switching between map types.
<m:map width="90%" height="90%" latitude="24" longitude="15">
<m:eventListener eventName="moveend" jsFunction="mapMoveEndHandler"/>
</m:map>This will create an event listener to the map, which will execute the (mapMoveEndHandler) function when the map (moveend) event occurs.
<m:polygon lineWidth="4">
<m:point latitude="30.01" longitude="31.14"/>
<m:point latitude="-33" longitude="19"/>
<m:point latitude="39" longitude="-101"/>
<m:point latitude="30.01" longitude="31.14"/>
</m:polygon>This will attach a polygon of the listed four points to the map. Note that the first point should be the same as the last one.
<m:polyline>
<m:point latitude="30.01" longitude="31.14"/>
<m:point latitude="-33" longitude="19"/>
<m:point latitude="39" longitude="-101"/>
</m:polyline>This will attach a polyline of the listed three points to the map.
<m:map width="90%" height="90%" latitude="24" longitude="15" zoom="2">
<m:groundoverlay imageURL="http://www.jroller.com/HazemBlog/resource/gmaps4jsf-logo.png"
startLatitude="7" endLatitude="23"
startLongitude="-54" endLongitude="84" />
</m:map>This will attach the GMaps4JSF logo to the map, placing the image in the box starting from latlng(7, -54), and ending at latlng(23, 84).
<m:streetViewPanorama width="500px" height="500px"
latitude="42.345573" longitude="-71.098326" />
This will create a simple street view panorama of height = 500px and width = 500px, and the panorama will point to latitude = 42.345573 and longitude = -71.098326.
|
Sign in to add a comment
map still not showing up
I used this API on Google Maps' China service http://ditu.google.com/... Many of the tags do not work, such as showing the map control, and using jsVariable to refer the map. (Same code works for maps.google.com service.) Do you know if this is because ditu.google.com does not provide the full API that maps.google.com offers?
Sheldon
I used the library at my Jboss Seam project. I changed the web.xml to support facelets and although it seems to transact with google.com the map is still not showing up. I don't know if this is an issue so I posted it here. Any idea?
@aris: I will make a sample on JBoss seam and upload it soon! Thanks for telling us.
Thanks for the really fast reply. Looking forward...
This is caused by the jar not conforming to facelets taglib rules: https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-web
Just open the jar and rename gmaps4jsf-facelets.xml to gmaps4jsf.taglib.xml and the tag will be properly parsed. Now for the map showing up properly...that's a whole different story
GMaps4JSF works fine with Facelets, and the map is shown up, check this: http://gmaps4jsf.googlecode.com/files/gmaps4jsf1.1.1-facelets.war
Please if any body finds a specific case or issue, Can s(he) open an issue here: http://code.google.com/p/gmaps4jsf/issues/list
The google map works fine in my page, but if I add <m:streetViewPanorama /> componment, the map does not work anymore and pops up "Stack overflow" error.
Has anybody checked if addresses in native languages are supported? If I put an address string in Russian it gives me "(GClientGeocoder) service not found the address location". I wonder if page encoding might be not correct (utf8 was used).
@ibalashov Turned out to be a GET encoding issue. Solved with putting useBodyEncodingForURI="true" into Tomcat's server.xml
i'm using gmaps4jsf with icefaces. apearantly the initializing js method of the map isn't called when a ajax request is done. this leads to a blank map. any1 got a workaround for that? greetings and thanks
I'm having the same issue with Icefaces...
@sot, @ brent:
Did you try the latest snapshot (http://gmaps4jsf.googlecode.com/files/gmaps4jsf-core-1.1.2-SNAPSHOT-28-May-2009.jar)
If you try it and it causes the same bug, I appreciate if you open an issue, and send me a link to your war so I can solve this defect if exists.
Thanks!
To get it working with IceFaces?, put this in the constructor of your backing bean:
import com.icesoft.faces.context.effects.JavascriptContext?;
JavascriptContext?.includeLib("http://maps.google.com/maps?file=api&v=2&key=abcdefg", FacesContext?.getCurrentInstance());
For IceFaces? partial rendering to work, you must set the renderOnWindowLoad attribute for the Gmaps4JSF:
Hi Hazem We use gmaps4JSF gmaps4jsf-core-1.1.2-SNAPSHOT-20-June-2009.jar Liferay portal server5.2.2 icefaces1.8.0 After using the attribute renderOnWindowLoad="false", we are able to see map in few locations. But it does not work in few places, gives a blank screen. Works fine in IE7 but gives problem in IE8 with VISTA and Firefox3.5 on Windows XP and Vista. If I see view source, i can see the Gmap script there.. but map is not rendered. May be the initialization code is not getting rendered.. blank screen looks bad... Can you please help.
Getting the same problem as Girish etc. The m:map doesn't render my map.
I using the GMaps4JSF 1.1.2 jar
If I add the RichFaces? gmap tag;
<rich:gmap/>
Both maps render!
Using 1.1.2 with ICEfaces, also can't get the map to show up :(
Tried the renderOnWindowsLoad="false", no luck.
I got it! I added more standard JSF libraries to my project. Hope this helps someone else.
I added more standard JSF libraries to my project
Can you expand? Which libraries did you add?