|
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.
|
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?
Guys, Can you please send all of your questions to the project group?
As there is no way to notify me with your comments.
Thanks all!
I need to get lat and lng. How can I do it?
Super cool... wonderful
Hi, i am using the key in script and trying to call the <m:map> tag with latLang but map is not rendering. using jsf with richfaces. any suggestion or configuration? thanks
Hi. I have a quick question. Please consider the following scenario: I'm writing portlets using Liferay and ICEFaces and wanted to use the GMAPS4JSF library for the google map portlet.
I'm doing a search in the backend, so my backing bean has got a List of Objects to show on the map. My requirement is to present the results on the map (done via ui:repeat tag and inside creating markers using m:marker ) and also on a list next to it. Once a user clicks on a marker, then the associated result list item should be highlighted. And vice versa.
Now I thought on using the jsVariable attribute on each marker. Variable name somehow generated based on unique id of the associated result item. In plain javascript somewhere I want to get my hands on the marker objects in order to do something with them, e.g. highlight them by exchanging the icon.
So in my opinion I need access to the marker objects somehow by the generated id (variable name). Are the generated markers somehow get stored in a array, so that I can get my hands on them by the id? Or is it possible to loop over the markers based on the map object itself.
Any ideas how to solve that problem using gmaps4jsf or is that something the library can not provide?
Thanks.
hi, I just want to ask for this part: <m:map address="#{addressBean.address}">
If i use the address in m:map, then the address will show up in the map, but if I will to use the address in m:marker, then it will not show up. Is it supposed to be a bug or ?Right now I am using in this way and the address didn't show up: <m:map >
but if I am using in this way, the address will be shown in the map: <m:map address="#{addressBean.address}">
@stealthshooter: use map autoReshape = true.
I am looking this weblink http://www.mashups4jsf.com/gmaps4jsf-examples/home.jsf Although it provided some examples on how the gmap4jsf is used (i.e how the coding for the website), but it does not provide the coding for the backing bean. Is there any resource of how the backing bean is coded for the example?
Here is the code: http://code.google.com/p/gmaps4jsf/source/browse/#svn/trunk/examples/src/main/java/com/googlecode/gmaps4jsf/example/beans
Is there a way to change markers color and letter?
does this work with the api that doesnt use api key? the v3 google maps api?
nah, map not showing up on my netbeans web app project with JSF 2.0, firebug shows me this error An attempt was made to use an object that is not, or is no longer, usable" code: "11 and im making everything the same they say here... dont know what to do... damm :S
Hi, I found that I need to enclose the <m:map> tag in <h:form> tag for the map to work (which is not mentioned in this particular wiki page). However, <m:streetViewPanorama/> tag does not require a form tag to work.
-- Using gmaps4jsf1.1.4 + JSF
hi every one :) i want to ask how to attach an image to a marker !!!!!i want an image that appears in the palce of the marker thks
Check the following example: http://www.mashups4jsf.com/gmaps4jsf-examples/pages/customMarkers.jsf http://www.mashups4jsf.com/gmaps4jsf-examples/pages/customMarkers.jsp.source
Great work.
Thank you Mr. Hazem for your great effort
adding several routes? eg from A to B and from B to C
Fantastic framework - great Job! I have one question - why does the autoReshape="true" doesn't work with 1 marker? In my opinion the map should load centering itself on the marker but in my case it always starts in Cairo... I am populating the markers with a dynamic list in Java (retried from a DB). When there are more than 1 markers the map fits nicely to show each. But if in some cases the list would have only 1 location and then I cannot auto-center it on map at startup. Any advice?
Hi Adam,
Just specify a default address or a default longitude and latitude to override the default value which is "Cairo, Egypt". Map by default is centered with the value specified in the address or longitude and latitude attributes of the map.
Hi Hazem,
Again, great job - the framework is Awesome. The problem is that I populate the map with markers generated dynamically and I use autoReshape="true". But If I define the default address or long/lat the map would ignore the autoReshape option. Some solutions that comes to my head is to define 2 <map> tags on the page and manipulate with 'render' attribute: one for more than 1 marker when I use atoReshape, and the second one for situation when I have a single marker and then define map address on it. This however seems to be a very ugly solution so I haven't checked if it works yet.
Hi Hazem,
When I was googling for a solution, google throw me a link to the source code of the framework. I haven't analyzed it throughly so I am not sure if it is really the case. Take a look at lines 71-81 in gmaps4jsf-map.js file. I guess to solve my problem, there should be a 'if else' option with (this.properties.autoReshape && (this.markers.length == 1)). Maybe you cover that somwhere else but the behaviour I am seeing is different. So again - I don't want to sound like mr. smartypants but just maybe give you a clue what can be the problem.
OH just to be sure - I use 1.1.4 version.
Hi
I am trying to use it with JSF 2.0 (JSPs) by including GMaps4JSF1.1.4 jar on my build path. But the page fails to display any maps..It shows a blank space...
The <map:> component is included inside the <h:form>. The taglib is correctly added.The js includes the api key and the jars are added to build path..
Can anyone let me know where am I going wrong..
m:map width="500px" height="300px" latitude="41.033386" longitude="-73.781755" />
Hi
Thanks Ganesh
How to change color of m:htmlInformationWindow htmlText? I am using theme where text is white, so information window is always empty or not empty, white font in white backgraound.
Thanks Sami