google-mapsmobilesencha-touchopenlayersmashup

openlayers for mobile devices


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!


Solution

  • 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.