我正在构建一个简单的网络应用程序,以显示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>
[...]
我从一个应该工作的示例中复制了代码...但是我看不到地图。
我的类路径上有gmaps4jsf-core-3.0.0.jar,我想我不需要配置其他任何东西了吗?
编辑:似乎标签未被识别。当我在浏览器中单击“查看源代码”时,gmaps标记未“翻译”,当我在xhtml文件中编写它们时,它们就会显示出来。
最佳答案
如果您的标签没有被翻译,则很可能是jar文件放置在错误的位置。某些事情是避免您的Web应用找到它。您是如何建造的?
将最新的库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>
问候,