[OpenLayers-Users] RE: mytopo layer for USGS topo insead of terraservice?

geoffff osgeo at 8pup.net
Sun Jun 26 19:03:15 EDT 2011


I switched from Openlayers to Google Maps APIs about a year ago, but here is my old code if you’d like to look at it (attached testgeoff.zip).  I just tried it on my server, and it still works – tiles aren’t blank for me.

 

The key code is below, where I set up a “TMS” tile request callback.

 

As a sanity check, if you zoom into zoom level 15 at “Four Corners” (37.0000 N, 109.0000 W), your code should be requesting this tile:

 

http://maps.mytopo.com/YOURAPIKEY/tilecache.py/1.0.0/topoG/15/6458/12754.png

 

For instance, this works for me in my web browser:

 

http://maps.mytopo.com/digital-topo/tilecache.py/1.0.0/topoG/15/6458/12754.png

 

Make sure you have requested your own API key from  <mailto:support at mytopo.com> support at mytopo.com  

 

I do seem to get blank tiles (failed requests) sometimes when I use other sites’ API keys.

 

-- Geoff

 

 

 

        ///////////////////////////////////////////////////////////////////////////////////////////

        // Tile URL generator for mytopo

        function TMS_GetTileURL(bounds) {

 

           var res = this.map.getResolution();

 

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

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

           var z = this.map.getZoom();

 

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

           }

 

[…]

 

            // var mySite = 'boontracker';

            // var mySite = 'digital-topo';

            var mySite = 'mytopo';  // replace with your site name, registered with mytopo

 

            layerMytopo = new OpenLayers.Layer.TMS(

                "Topo",

                "http://maps.mytopo.com/"+mySite+"/tilecache.py/1.0.0/topoG/",

                {

                    type: 'png',

                    getURL: TMS_GetTileURL,

                    displayOutsideMaxExtent: false,

                    attribution: '<a href="http://www.mytopo.com/index.cfm">&copy; MyTopo.com</a>',

                    numZoomLevels: 17

                }

            );

 

 





 



--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/mytopo-layer-for-USGS-topo-insead-of-terraservice-tp5700129p6518352.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110626/fe1476e3/attachment.html


More information about the Users mailing list