2011-01-21 37 views
10

Uso de PrimeFaces 2.2.RC2 en un proyecto JSF 2.0.PrimeFaces gmap no rendering

Estoy tratando de obtener un mapa de Google básico para representar con el componente gmap. Ningún error aparece solo en la página en blanco donde debería estar el mapa.

Mi archivo .xhtml

<?xml version='1.0' encoding='UTF-8' ?> 
<!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:p="http://primefaces.prime.com.tr/ui"> 

    <h:head> 
     <script src="http://maps.google.com/maps/api/js?sensor=false" 
       type="text/javascript"></script> 
    </h:head> 
    <h:body> 
     <f:view contentType="text/html"> 
      <h1>Google Map</h1> 
      <p:gmap center="41.381542, 2.122893" zoom="15" type="HYBIRD" 
        style="width:600px;height:400px" /> 
     </f:view> 
    </h:body> 
</html> 

no tenían problemas para conseguir otros componentes PrimeFaces para rendir en este proyecto y el example en los PrimeFaces página web en el navegador presta muy bien.

¿Alguna idea?

Actualización:

He cambiado la etiqueta de fin de <f:view contentType="text/html">, ahora me sale un cuadro gris en el que el mapa debe ser y cuando se ciernen sobre el cuadro el cursor se convierte en mano blanca para agarrar y mover el mapa alrededor, pero aún no muestra el mapa.

alt text

Respuesta

5

<f:view contentType="text/html"> se necesita para que funcione en Safari/Chrome

Mi otro problema se híbrido fue mal escrito, las siguientes obras:

<h1>Google Map 1</h1> 
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID" 
    style="width:600px;height:400px" /> 

Spelling nunca fue mi fuerte .

0

Prueba esto:

<h:form> 
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"  
style="width:600px;height:400px" streetView="true"/> 
</h:form> 
26

es necesario agregar este script para que la página:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" ></script> 
+0

Me salvaste el día! – Sarz

+0

Solo como una nota. El parámetro del sensor ya no es necesario. ver: http://stackoverflow.com/questions/8616764/what-is-the-sensor-parameter-in-google-places-api-good-for – Koekiebox

2

Esto funciona para mí

<h:head> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" 
      type="text/javascript"></script> 
</h:head> 
<h:body> 
    <f:view contentType="text/html"> 
     <h1>Google Map</h1> 
     <p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID" style="width:600px;height:400px" /> 
    </f:view> 
</h:body> 
+0

Agregar etiqueta de script en firefox 33 es suficiente para mí. ¡Gracias! –