Single argument constructor for UTFGrid layer.

This commit is contained in:
Tim Schaub
2012-03-03 16:05:58 -07:00
parent 2feb860983
commit 36d22bbb15
4 changed files with 36 additions and 34 deletions

View File

@@ -1,10 +1,10 @@
var osm = new OpenLayers.Layer.OSM();
var utfgrid = new OpenLayers.Layer.UTFGrid(
"Invisible UTFGrid Layer",
"./utfgrid/world_utfgrid/${z}/${x}/${y}.json",
{utfgridResolution: 4} // default is 2
);
var utfgrid = new OpenLayers.Layer.UTFGrid({
url: "utfgrid/world_utfgrid/${z}/${x}/${y}.json",
utfgridResolution: 4, // default is 2
displayInLayerSwitcher: false
});
var map = new OpenLayers.Map({
div: "map",

View File

@@ -1,15 +1,15 @@
var osm = new OpenLayers.Layer.OSM();
var population = new OpenLayers.Layer.UTFGrid(
"World Population",
"./utfgrid/world_utfgrid/${z}/${x}/${y}.json",
{utfgridResolution: 4} // default is 2
);
var bioregions = new OpenLayers.Layer.UTFGrid(
"World Bioregions",
"./utfgrid/bio_utfgrid/${z}/${x}/${y}.json",
{utfgridResolution: 4} // default is 2
);
var population = new OpenLayers.Layer.UTFGrid({
name: "World Population",
url: "utfgrid/world_utfgrid/${z}/${x}/${y}.json",
utfgridResolution: 4 // default is 2
});
var bioregions = new OpenLayers.Layer.UTFGrid({
name: "World Bioregions",
url: "utfgrid/bio_utfgrid/${z}/${x}/${y}.json",
utfgridResolution: 4 // default is 2
});
var map = new OpenLayers.Map({
div: "map",

View File

@@ -19,9 +19,10 @@
* Example:
*
* (start code)
* var world_utfgrid = new OpenLayers.Layer.UTFGrid(
* 'UTFGrid Layer',
* "http://tiles/world_utfgrid/${z}/${x}/${y}.json"
* var world_utfgrid = new OpenLayers.Layer.UTFGrid({
* url: "/tiles/world_utfgrid/${z}/${x}/${y}.json",
* utfgridResolution: 4,
* displayInLayerSwitcher: false
* );
* map.addLayer(world_utfgrid);
*
@@ -99,14 +100,18 @@ OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.Grid, {
/**
* Constructor: OpenLayers.Layer.UTFGrid
* Create a new UTFGrid layer.
*
* Parameters:
* name - {String}
* url - {String}
* options - {Object} Hashtable of extra options to tag onto the layer
* config - {Object} Configuration properties for the layer.
*
* Required configuration properties:
* url - {String} The url template for UTFGrid tiles. See the <url> property.
*/
initialize: function(name, url, options) {
OpenLayers.Layer.Grid.prototype.initialize.apply(this, [name, url, {}, options]);
initialize: function(options) {
OpenLayers.Layer.Grid.prototype.initialize.apply(
this, [options.name, options.url, {}, options]
);
this.tileOptions = OpenLayers.Util.extend({
utfgridResolution: this.utfgridResolution
}, this.tileOptions);
@@ -117,17 +122,14 @@ OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.Grid, {
* Create a clone of this layer
*
* Parameters:
* obj - {Object} Is this ever used?
* obj - {Object} Only used by a subclass of this layer.
*
* Returns:
* {<OpenLayers.Layer.UTFGrid>} An exact clone of this OpenLayers.Layer.UTFGrid
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.UTFGrid(this.name,
this.url,
this.getOptions());
obj = new OpenLayers.Layer.UTFGrid(this.getOptions());
}
// get all additions from superclasses

View File

@@ -22,11 +22,11 @@
var map, layer;
function setUp() {
layer = new OpenLayers.Layer.UTFGrid(
null,
"../data/utfgrid/world_utfgrid/${z}/${x}/${y}.json",
{isBaseLayer: true, utfgridResolution: 4}
);
layer = new OpenLayers.Layer.UTFGrid({
url: "../data/utfgrid/world_utfgrid/${z}/${x}/${y}.json",
isBaseLayer: true,
utfgridResolution: 4
});
map = new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",