当我从3.4迁移到5.0时,PrimeFaces GMap控件不起作用

时间:2014-08-30 10:38:43

标签: google-maps primefaces

我有一个很大的问题。 我在PrimeFaces 3.4中用JSF 2.1和JAVA6编写了一个项目。我正在实现从PF 3.4到PF 5.0的移植 但是使用PF 5.0,组件GMap根本不起作用!当我加载页面时,GMap不会呈现,它看起来完全是白色。

Firebug说:谷歌没有定义......

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<f:view 
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.org/ui"

contentType="text/html">
<h:head>
<script src="https://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="#{request.contextPath}/css/garantesStyles.css" />


<title>My App title</title>
</h:head>

<h:body >
    <p:ajaxStatus onstart="PF('statusDialog').show();" onsuccess="PF('statusDialog').hide();"/>  

    <p:dialog modal="true" widgetVar="statusDialog" header="Attendere..."   
            draggable="false" closable="false">  
        <p:graphicImage value="/images/ajaxloadingbar.gif" />  
    </p:dialog>  

            <h:form id="formOggettoMappa">
        <p:gmap widgetVar="oggettoMappa" id="oggettoMappa" center="#{mapUrbanBean.centerMap}" 
            zoom="#{mapUrbanBean.zoomFactor}"    type="hybrid"
            style="width:100%;height:600px"   model="#{mapUrbanBean.puntiModel}" > 
            <p:ajax event="overlaySelect" listener="#{mapUrbanBean.onMarkerSelect}" />  

        </p:gmap>
        </h:form>

这是关于我的bean的代码

@ManagedBean(name="mapUrbanBean")
@SessionScoped

public class MapBean implements Serializable {

    private static final long serialVersionUID = 1L;
        private MapModel puntiModel;
        private double centerX,centerY,zoomFactor;
        private String centerMap;


        public MapModel getPuntiModel() {
            return puntiModel;
        }

        public void setPuntiModel(MapModel puntiModel) {
            this.puntiModel = puntiModel;
        }


        public String getCenterMap() {
            return centerMap;
        }

        public void setCenterMap(String centerMap) {
            this.centerMap = centerMap;
        }

        public double getCenterX() {
            return centerX;
        }

        public void setCenterX(double centerX) {
            this.centerX = centerX;
        }

        public double getCenterY() {
            return centerY;
        }

        public void setCenterY(double centerY) {
            this.centerY = centerY;
        }

        public int getZoomFactor() {
            return zoomFactor;
        }

        public void setZoomFactor(int zoomFactor) {
            this.zoomFactor = zoomFactor;
        }



    @PostConstruct
    public void init(){
        this.data = new Date();
        this.data2 = new Date();
        popolaUltimiMappa();

    }


   public void popolaUltimiMappa(){
        puntiModel= new DefaultMapModel();       

        LatLng coord = new LatLng(36.890257,30.707417);
        puntiModel.addOverlay(new Marker(coord, "this marker","images/mapimg/"+img_a.get(i)));
        this.centerX=36.890257;
        this.centerY=30.707417;
        this.zoomFactor=13;
        this.centerMap= this.centerY+ "," +this.centerX;

   }

}

此代码适用于PrimeFaces 3.4,但使用PrimeFaces 5.0则不起作用。

我试过谷歌,但我一无所获。

任何想法????

提前谢谢

编辑:我看到GMap控件正常工作(显示一些图层),但禁用了任何控件!我无法做任何事情,任何平移动作,任何放大或缩小操作......

1 个答案:

答案 0 :(得分:0)

是的,和我一样的问题。但如果你使用谷歌地图的普通javascript它会工作,我认为它只会在本地网页应用程序上使用,而不是谷歌应用程序引擎。