gwt-openlayers 和 openstreetmap 示例
我想将 OSM 集成到 GWT 中。 我找到了这个名为 gwt-openlayers 的库,但我不明白如何使其与 OSM 映射一起使用。
谁能给我提供一个简短的例子?
I'd like to integrate OSM in GWT.
I found this library called gwt-openlayers, but I don't understand how can I make it work with the OSM map.
Can anyone provide me a short example?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保通过将以下内容添加到模块文件中来继承 gwt-openlayers:
另外,请确保引入 OpenLayers javascript通过在“Application.html”页面中添加以下行,将库和 OpenStreetMap OpenLayers 添加到您的应用程序中:
那么创建起来应该很简单使用开放街道地图的图层:
OSM openStreetMap = OSM.Osmarender("Base Map");
openStreetMap.setIsBaseLayer(true);
MapWidget mapWidget = new MapWidget("350px", "350px");
mapWidget.getMap().addLayer(openStreetMap);
Make sure you inherit from gwt-openlayers by adding the following to your module file:
<inherits name='org.gwtopenmaps.openlayers.OpenLayers'/>
Also make sure you bring in the OpenLayers javascript library and OpenStreetMap OpenLayers into your application by adding the following lines in "Application.html" page:
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
Then it should a simple thing to create a layer that uses open street maps:
OSM openStreetMap = OSM.Osmarender("Base Map");
openStreetMap.setIsBaseLayer(true);
MapWidget mapWidget = new MapWidget("350px", "350px");
mapWidget.getMap().addLayer(openStreetMap);
GWT-OpenLayers
HelloWorld
与 OpenStreetMap下面的示例对我来说效果很好,使用
OpenLayers-2.8/OpenLayers.js
和OpenStreetMap.js< /code>如上所述:
GWT-OpenLayers
HelloWorld
with OpenStreetMapThe following example works fine for me using
OpenLayers-2.8/OpenLayers.js
andOpenStreetMap.js
as described above:您可以在此处找到 gwt-openlayers 的当前版本: http://sourceforge.net/projects/gwt-openlayers /
you find the current version of gwt-openlayers here: http://sourceforge.net/projects/gwt-openlayers/