我正在构建一个简单的webapp,它显示来自GoogleMaps的地图,其中包含从我的数据库加载的多个标记...但我无法将其渲染...
我正在使用JSF 2和gmaps4jsf。
我的页面如下:
<!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>
[...]
我从一个应该工作的例子中复制了代码......但是我看不到地图。
我的classpath上有gmaps4jsf-core-3.0.0.jar,我想我不需要配置其他任何想法?
编辑:似乎没有识别标签。当我点击浏览器中的“查看源代码”时,gmaps标签不会被“翻译”,它们会在我在xhtml文件中编写时显示。
答案 0 :(得分:4)
如果你的标签没有被翻译,最可能的是jar文件在错误的地方。有些东西正在避免你的webapp找到它。你是如何建造它的?
将最新的库jar放在您的Web应用程序 WEB-INF / lib 文件夹中。
m:map 必须位于 h:form 标记内。
由于您的图书馆版本,您应该包含一个javascript代码:
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?sensor=true">
</script>
看看这个simple example for using gmaps4jsf2 library。
您是否先使用非常基本的配置?
<!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>
此致