[OpenLayers-Users] doe Open layers mobile support tms layers?

miguel juanabreu at hotmail.com
Fri Jan 25 07:25:15 PST 2013


Guys 

I've been struggling for days try to get a TMS layer that works on the web
without any issues to the mobile environment. The basic question is does the
Mobile environment support the TMS layers? I have a simple floor plan that
I'm trying to publish using the open layer mobile. However I'm just quite
honestly stumbling on my own two feet here. Can someone offer some example?
Or can the library even do this?  here is some sample code, for some reason
this only shows two tiles? The lower two tiles is actually quite
frustuating. thanks in advance for any help you guys can offer.

 

<style>

 

html, body{height:400px;

           width:400px;

          }

           

#map { height: 400px;

       border: 1px solid #E0E0DF; }

 

</style>

 

 

 

<head runat="server">

    <meta content="yes" name="apple-mobile-web-app-capable"/>

    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0,
user-scalable=0" name="viewport"/>

 

    <title> </title>

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

    <script
src="http://openlayers.org/dev/lib/OpenLayers/Layer/TMS.js"></script> 

    <script src="JS/jquery-1.8.2.min.js" type="text/javascript"></script>

    <link rel="stylesheet"
href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />

    <script type="text/javascript"
src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></scrip
t>

  

    <link href="../JS/theme/default/style.mobile.css" rel="stylesheet"
type="text/css" />

 

<script type="text/javascript">

    var map;

    var mapBounds = new OpenLayers.Bounds(-180.0, -317.7, 180.0, 90.0); 

    var mapMinZoom = 0;

    var mapMaxZoom = 3;

 

    // avoid pink tiles

    OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;

    OpenLayers.Util.onImageLoadErrorColor = "transparent";

 

    function init() {

 

 

        var options = {

            controls: [],

            maxExtent: new OpenLayers.Bounds(-180.0, -317.7, 180.0, 90.0),

            maxResolution: 1.800000,

            numZoomLevels: 4

        };

 

 

        map = new OpenLayers.Map('map');

 

        var layer = new OpenLayers.Layer.TMS("TMS Layer",
"http://www.blahblah.com/MAP2/",

                   { url: "", serviceVersion: '.', layername: '.', alpha:
true,

                     type: 'png', getURL: overlay_getTileURL

                   });

 

        map.addLayer(layer);

        map.zoomToExtent(mapBounds);

    };

 

        function overlay_getTileURL(bounds) {

            var res = this.map.getResolution();

            var x = Math.round((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));

            var y = Math.round((bounds.bottom - this.maxExtent.bottom) /
(res * this.tileSize.h));

            var z = this.map.getZoom();

            if (x >= 0 && y >= 0) {

                return this.url + z + "/" + x + "/" + y + "." + this.type;

            } else {

                return "http://www.maptiler.org/img/none.png";

            }

        }

    

 

</script>

 

 

 

 

</head>

 

<body onload="init()" >

 

       

                <div id="map"></div>

        

 

</body>

</html>

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130125/36eedd29/attachment-0001.html>


More information about the Users mailing list