p:gmap with Prime 2.1.RC.SNAPSHOT doesn't work ?

UI Components for JSF
Post Reply
Tream84
Posts: 33
Joined: 27 Jun 2010, 12:46

27 Jun 2010, 12:56

Hi,
i use the Libary Prime 2.1.RC.SNAPSHOT because i want use some Themes. I try to include g:map but on my page nothing appear. Why ?

Server: Glassfish v3
Jsf : JSF 2.0

mapManagedBean.java

Code: Select all


package managedBeans;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.map.PointSelectEvent;
import org.primefaces.event.map.StateChangeEvent;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.LatLngBounds;

@ManagedBean(name="mapBean")
@RequestScoped
public class mapManagedBean implements Serializable {

	public void onStateChange(StateChangeEvent event) {
		LatLngBounds bounds = event.getBounds();
		int zoomLevel = event.getZoomLevel();

		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Zoom Level", String.valueOf(zoomLevel)));
		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Center", bounds.getCenter().toString()));
		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "NorthEast", bounds.getNorthEast().toString()));
		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "SouthWest", bounds.getSouthWest().toString()));
	}

	public void onPointSelect(PointSelectEvent event) {
		LatLng latlng = event.getLatLng();

		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Point Selected", "Lat:" + latlng.getLat() + ", Lng:" + latlng.getLng()));
	}

	public void addMessage(FacesMessage message) {
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
}

index.xhtml

Code: Select all

<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:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <meta http-equiv="content-type"
              content="application/xhtml+xml;charset=utf-8" />
    </h:head>
    <h:body>
        <ui:composition template="/WEB-INF/template/mainTemplate.xhtml">
            <ui:define name="content">
                <p:panel header="GoogleMap">
                    <h:form>
                        <p:growl id="messages" showDetail="true" life="2000" />

                        <p:gmap center="41.381542, 2.122893" zoom="15" type="ROADMAP"
                                style="width:600px;height:400px"
                                stateChangeListener="#{mapBean.onStateChange}" onStateChangeUpdate="messages"
                                pointSelectListener="#{mapBean.onPointSelect}" onPointSelectUpdate="messages" />
                    </h:form>
                </p:panel>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

Tream84
Posts: 33
Joined: 27 Jun 2010, 12:46

27 Jun 2010, 13:02

I found the Answer in anotuher Thread.

Solution:

Simply add the following in your html header:

Code:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sens ... "></script>

This Thread can be closed... Sorry for posting

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Jun 2010, 13:11

Yes, you need to add the gmap script.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 43 guests