[GIS] display WMS layer from geoserver in mobile app with openlayers mobile

geoservermobileopenlayers-2

i try to display WMS layer from geoserver with openLayers Mobile,and its working great in the navigator (chrome) but its not appeering in the simulator device (android)…
& with another WMS layer like open street map , its working perfectly in both, web navigator and android device , so i can't figure out where the problem is , its been more then 10 days and i can't handle this problem..

this is my code:

var map;
    OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

    function init() {
        map = new OpenLayers.Map('map', {
                controls: [
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                    new OpenLayers.Control.ScaleLine(),                    
                    new OpenLayers.Control.MousePosition()                       
                ]       
            });

            var wms = new OpenLayers.Layer.WMS(
                "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
                {layers: "basic"}
            );

           var osgeo = new OpenLayers.Layer.WMS("OpenLayers WMS",
                "http://vmap0.tiles.osgeo.org/wms/vmap0",
                {layers: 'basic'},
                {isBaseLayer: true, transitionEffect: 'resize'}
            );

          com = new OpenLayers.Layer.WMS(
            "communes",
            "http://localhost:8080/geoserver/wms",
            {layers: 'cite:matcommune_view', format: 'image/gif',transparent: true}
        );

       map.addLayers([osgeo, com]);

map.setCenter(new OpenLayers.LonLat(-104, 42), 3);

Best Answer

You are adding the layer using the following piece of code:

com = new OpenLayers.Layer.WMS(
            "communes",
            "http://localhost:8080/geoserver/wms",
            {layers: 'cite:matcommune_view', format: 'image/gif',transparent: true}
        );

If you read it carefully, you will see that you are calling it as localhost. Since the device is a different system, you will need to refer to it using a hostname, that is accessible from the virtual device. I usually use the IP address of the server.

Ideally, this application should be visible from outside of your internal network.(For example when you are testing on a real device with a cellular 3G network) For this, you will have to make sure that your Geoserver is accessible from outside. You will then have to give the external IP or the domain name.