用于移动设备的 openlayers

发布于 2024-11-27 19:06:20 字数 492 浏览 1 评论 0原文

新手问题:在使用 openlayers 的移动 Web 开发中,我需要在标头中包含哪个 lib 文件?我的意思是,是 openlayers.js 还是 openlayers.mobile.js?

<script type="text/javascript" src="lib/OpenLayers.mobile.js"></script>

或者

<script type="text/javascript" src="lib/OpenLayers.js"></script>

实践中会有一些差异吗?

我之所以问这个问题是因为我想用GoogleMaps开发一个mashup应用程序;但是,如果我不包含 openlayers.js 而是放入 openlayer.mobile,则“Openlayers.layer.Google”将无法被识别。

感谢您的回复!

A newbie question: in mobile web development using openlayers, which lib file do I need to include in the header? I mean, is it openlayers.js or openlayers.mobile.js?

<script type="text/javascript" src="lib/OpenLayers.mobile.js"></script>

or

<script type="text/javascript" src="lib/OpenLayers.js"></script>

Will there be some difference in practice?

The reason why I ask this is that I want to develop a mashup app with GoogleMaps; however, if I don't include openlayers.js but instead put openlayer.mobile, then "Openlayers.layer.Google" won't be recognized.

Thanks for any replies!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔日梦未散 2024-12-04 19:06:20

默认 OpenLayers.mobile.js 是使用“mobile.cfg”配置文件构建的,如下所示:

[first]

[last]

[include]
OpenLayers/Map.js
OpenLayers/Kinetic.js
OpenLayers/Projection.js
OpenLayers/Layer/SphericalMercator.js
OpenLayers/Layer/XYZ.js
OpenLayers/Layer/Bing.js
OpenLayers/Layer/WMS.js
OpenLayers/Format/WMSGetFeatureInfo.js
OpenLayers/Control/TouchNavigation.js
OpenLayers/Control/Geolocate.js
OpenLayers/Control/ZoomPanel.js
OpenLayers/Control/Attribution.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Control/DrawFeature.js
OpenLayers/Control/ModifyFeature.js
OpenLayers/Control/WMSGetFeatureInfo.js
OpenLayers/Control/Panel.js
OpenLayers/Handler/Point.js
OpenLayers/Handler/Path.js
OpenLayers/Handler/Polygon.js
OpenLayers/Layer/Vector.js
OpenLayers/Layer/TileCache.js
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/Canvas.js
OpenLayers/Format/GeoJSON.js
OpenLayers/Format/KML.js
OpenLayers/Protocol/HTTP.js
OpenLayers/Protocol/WFS.js
OpenLayers/Protocol/WFS/v1_0_0.js
OpenLayers/Strategy/Fixed.js

[exclude]

正如您所看到的,其中没有 OpenLayers.Layer.Google。这就是你收到错误的原因。
因此,我建议您继续构建自己的 OpenLayers 版本,其中仅包含您需要的内容(例如,您可能需要删除 OpenLayers.Layer.Bing)。

这里有一个很好的指南告诉你如何做到这一点。

Default OpenLayers.mobile.js is built with 'mobile.cfg' profile that looks like this:

[first]

[last]

[include]
OpenLayers/Map.js
OpenLayers/Kinetic.js
OpenLayers/Projection.js
OpenLayers/Layer/SphericalMercator.js
OpenLayers/Layer/XYZ.js
OpenLayers/Layer/Bing.js
OpenLayers/Layer/WMS.js
OpenLayers/Format/WMSGetFeatureInfo.js
OpenLayers/Control/TouchNavigation.js
OpenLayers/Control/Geolocate.js
OpenLayers/Control/ZoomPanel.js
OpenLayers/Control/Attribution.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Control/DrawFeature.js
OpenLayers/Control/ModifyFeature.js
OpenLayers/Control/WMSGetFeatureInfo.js
OpenLayers/Control/Panel.js
OpenLayers/Handler/Point.js
OpenLayers/Handler/Path.js
OpenLayers/Handler/Polygon.js
OpenLayers/Layer/Vector.js
OpenLayers/Layer/TileCache.js
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/Canvas.js
OpenLayers/Format/GeoJSON.js
OpenLayers/Format/KML.js
OpenLayers/Protocol/HTTP.js
OpenLayers/Protocol/WFS.js
OpenLayers/Protocol/WFS/v1_0_0.js
OpenLayers/Strategy/Fixed.js

[exclude]

As you can see there is no OpenLayers.Layer.Google in it. That's why you're getting error.
So I would recommend you to go ahead and build your own version of OpenLayers that would contain only stuff you need(you might want, for instance, remove OpenLayers.Layer.Bing).

Here is a good guide of how you do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文