4

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!

Brad Koch
  • 19,267
  • 19
  • 110
  • 137
Simon
  • 1,463
  • 6
  • 34
  • 46

1 Answers1

7

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.

igorti
  • 3,828
  • 3
  • 22
  • 29
  • very good advice. but why not just include the whole "openlayers.js"? do you think all of the features in "openlayers.js" could be well supported in mobile devices? thanks! – Simon Aug 07 '11 at 03:46
  • simply because mobile users are usually on mobile internet connection which is not fast and to load whole OpenLayers library(about 1 mb) can take quite a while. I didn't try all openlayers features on mobile devices, but the most common ones like showing different types of layers, drawing, measuring, etc. should work. – igorti Aug 07 '11 at 10:27