1 /*************************************** 2 * Copyright 2011, 2012 GlobWeb contributors. 3 * 4 * This file is part of GlobWeb. 5 * 6 * GlobWeb is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation, version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GlobWeb is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GlobWeb. If not, see <http://www.gnu.org/licenses/>. 18 ***************************************/ 19 20 define(['./Utils','./RasterLayer','./MercatorTiling'], function(Utils,RasterLayer,MercatorTiling) { 21 22 /**************************************************************************************************************/ 23 24 25 /** @name OSMLayer 26 @class 27 A layer to display data coming from OpenStreetMap server. 28 @augments RasterLayer 29 @param options Configuration properties for the OSMLayer. See {@link RasterLayer} for base properties : 30 <ul> 31 <li>baseUrl : the base Url to access the OSM server</li> 32 </ul> 33 */ 34 var OSMLayer = function( options ) 35 { 36 RasterLayer.prototype.constructor.call( this, options ); 37 this.tilePixelSize = options.tilePixelSize || 256; 38 this.tiling = new MercatorTiling( options.baseLevel || 2 ); 39 this.numberOfLevels = options.numberOfLevels || 21; 40 this.baseUrl = options.baseUrl; 41 } 42 43 /**************************************************************************************************************/ 44 45 Utils.inherits(RasterLayer,OSMLayer); 46 47 /**************************************************************************************************************/ 48 49 /** 50 Get an url for the given tile 51 */ 52 OSMLayer.prototype.getUrl = function(tile) 53 { 54 var url = this.baseUrl + '/' + tile.level + '/' + tile.x + '/' + tile.y + '.png'; 55 return url; 56 } 57 58 59 /**************************************************************************************************************/ 60 61 return OSMLayer; 62 63 }); 64