用于移动设备的 openlayers
新手问题:在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认 OpenLayers.mobile.js 是使用“mobile.cfg”配置文件构建的,如下所示:
正如您所看到的,其中没有 OpenLayers.Layer.Google。这就是你收到错误的原因。
因此,我建议您继续构建自己的 OpenLayers 版本,其中仅包含您需要的内容(例如,您可能需要删除 OpenLayers.Layer.Bing)。
这里有一个很好的指南告诉你如何做到这一点。
Default OpenLayers.mobile.js is built with 'mobile.cfg' profile that looks like this:
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.