GoogleMaps will not appear in JSF

I am creating a simple webapp that shows a map from GoogleMaps with a few tokens loaded from my database ... but I cannot get them to render ...

I am using JSF 2 and gmaps4jsf.

My page looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:m="http://code.google.com/p/gmaps4jsf/"> [...] <m:map width="500px" latitude="10.1" longitude="10.1" height="500px" zoom="6" autoReshape="true"> <ui:repeat var="loc" value="#{locs}"> <m:marker latitude="#{loc.latitude}" longitude="#{loc.longitude}"> <m:htmlInformationWindow htmlText="#{loc.latitude}-#{loc.longitude}" /> </m:marker> </ui:repeat> </m:map> [...] 

I copied the code from the example, which should work ... but I do not see the map.

I have gmaps4jsf-core-3.0.0.jar in my class path, I think I don't need to configure anything ... any ideas?

EDIT: It seems that the tags are not recognized. When I click "View Source" in the browser, the gmaps tags are not "translated", they are displayed when I wrote them in the xhtml file.

+4
source share
1 answer

If your tags are not translated, most likely this is because the jar file is in the wrong place. Something escapes your webapp to find it. How do you build it?

Place the last library jar in the WEB-INF / lib web application folder.

Your m: card must be inside the h: form tag.

Due to your version of the library, you have to include javascript code:

 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"> </script> 

Take a look at this simple gmaps4jsf2 library example .

Do you have a very simple configuration?

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:m="http://code.google.com/p/gmaps4jsf/"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/base-template.xhtml"> <ui:define name="js"> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"> </script> </ui:define> <ui:define name="title"> This is the new title </ui:define> <ui:define name="content"> <h1>Simple Map with a marker and an InfoWindow</h1> <h:form id="form"> <m:map width="500" height="450px" latitude="37.13" longitude="22.43" enableScrollWheelZoom="true"> <m:marker> <m:htmlInformationWindow htmlText="This is Sparta, Greece"/> </m:marker> </m:map> </h:form> </ui:define> </ui:composition> </html> 

Hello,

+4
source

Source: https://habr.com/ru/post/1482037/


All Articles