Skip to content

Commit

Permalink
v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
andygup committed Oct 13, 2014
1 parent f307932 commit 1039a76
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 35 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# offline-editor-js - Changelog

## Version 2.3 - Oct 13, 2014
- Closes #74 - Build sample with nice UX for editing
- Closes #257 - Build getting started pages for AGOL, editing and TPK. All samples show basic functionality and are responsive. Also integrated a new launch page for the API and How To Use docs.
- Closes #258 - Convert modal popup to widget
- The following samples were updated to be responsive:
- appcache-features.html
- appcache-tiles.html
- tpk-layer.html

New functionality:

- Closes #256 - Add getMaxZoom and getMinZoom to offlineTilesEnabler
- Added getMinMaxLOD() to offlineTilesEnabler and OfflineTilesEnablerLayer

Breaking Changes - None.


## Version 2.2.1 - Oct 1, 2014
Added a Getting Started for Tiles tutorial.

Expand Down
2 changes: 1 addition & 1 deletion dist/offline-edit-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor - v2.2 - 2014-09-30
/*! offline-editor-js - v2.3 - 2014-10-13
* Copyright (c) 2014 Environmental Systems Research Institute, Inc.
* Apache License*/

Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tiles-advanced-min.js

Large diffs are not rendered by default.

62 changes: 33 additions & 29 deletions dist/offline-tiles-advanced-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor - v2.2 - 2014-09-30
/*! offline-editor-js - v2.3 - 2014-10-13
* Copyright (c) 2014 Environmental Systems Research Institute, Inc.
* Apache License*/
define([
Expand Down Expand Up @@ -193,22 +193,9 @@ define([
getMaxZoom: function(callback){

if(this._maxZoom == null){
var lods = this.tileInfo.lods;
var length = this.tileInfo.lods.length;
var tempArr = [];
for(var i=0; i < length; i++){
tempArr.push(lods[i].level);
if(i == length -1){
tempArr.sortNumber();
this._maxZoom = tempArr[i];
callback(tempArr[i]);
}
}
this._maxZoom = this.tileInfo.lods[this.tileInfo.lods.length-1].level;
}
else{
callback(this._maxZoom);
}

callback(this._maxZoom);
},

/**
Expand All @@ -218,21 +205,38 @@ define([
getMinZoom: function(callback){

if(this._minZoom == null){
var lods = this.tileInfo.lods;
var length = this.tileInfo.lods.length;
var tempArr = [];
for(var i=0; i < length; i++){
tempArr.push(lods[i].level);
if(i == length -1){
tempArr.sortNumber();
this._minZoom = tempArr[0];
callback(tempArr[0]);
}
}
this._minZoom = this.tileInfo.lods[0].level;
}
callback(this._minZoom);
},

/**
* Utility method for bracketing above and below your current Level of Detail. Use
* this in conjunction with setting the minLevel and maxLevel in prepareForOffline().
* @param minZoomAdjust An Integer specifying how far above the current layer you want to retrieve tiles
* @param maxZoomAdjust An Integer specifying how far below (closer to earth) the current layer you want to retrieve tiles
*/
getMinMaxLOD: function(minZoomAdjust,maxZoomAdjust){
var zoom = {};
var map = this.getMap();
var min = map.getLevel() + minZoomAdjust;
var max = map.getLevel() + maxZoomAdjust;
if(this._maxZoom != null && this._minZoom != null){
zoom.max = Math.min(this._maxZoom, max); //prevent errors by setting the tile layer floor
zoom.min = Math.max(this._minZoom, min); //prevent errors by setting the tile layer ceiling
}
else{
callback(this._minZoom);
this.getMinZoom(function(result){
zoom.min = Math.max(result, min); //prevent errors by setting the tile layer ceiling
});

this.getMaxZoom(function(result){
zoom.max = Math.min(result, max); //prevent errors by setting the tile layer floor
});
}

return zoom;

},

/**
Expand Down Expand Up @@ -805,7 +809,7 @@ O.esri.Tiles.TilesCore = function(){
*/
this._getTiles = function(image,imageType,url,tileid,store,query){
store.retrieve(url, function(success, offlineTile)
{ console.log("TILE RETURN " + success + ", " + offlineTile)
{ console.log("TILE RETURN " + success + ", " + offlineTile.url)
/* when the .getTileUrl() callback is triggered we replace the temporary URL originally returned by the data:image url */
// search for the img with src="void:"+level+"-"+row+"-"+col and replace with actual url
image = query("img[src="+tileid+"]")[0];
Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tiles-basic-min.js

Large diffs are not rendered by default.

59 changes: 57 additions & 2 deletions dist/offline-tiles-basic-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor - v2.2 - 2014-09-30
/*! offline-editor-js - v2.3 - 2014-10-13
* Copyright (c) 2014 Environmental Systems Research Institute, Inc.
* Apache License*/
define([
Expand Down Expand Up @@ -37,6 +37,8 @@ define([
layer._tilesCore = new O.esri.Tiles.TilesCore();
layer._lastTileUrl = "";
layer._imageType = "";
layer._minZoom = null;
layer._maxZoom = null;

/* we add some methods to the layer object */
/* we don't want to extend the tiled layer class, as it is a capability that we want to add only to one instance */
Expand Down Expand Up @@ -242,6 +244,59 @@ define([
layer._tilesCore._loadFromFile(file,this.offline.store,callback);
};

/**
* Returns the maximum zoom level for this layer
* @param callback number
*/
layer.getMaxZoom = function(callback){
// TO-DO make this a simple return rather than a callback
if(this._maxZoom == null){
this._maxZoom = layer.tileInfo.lods[layer.tileInfo.lods.length-1].level;
}
callback(this._maxZoom);
},

/**
* Returns the minimum zoom level for this layer
* @param callback number
*/
layer.getMinZoom = function(callback){
// TO-DO make this a simple return rather than a callback
if(this._minZoom == null){
this._minZoom = layer.tileInfo.lods[0].level;
}
callback(this._minZoom);
};

/**
* Utility method for bracketing above and below your current Level of Detail. Use
* this in conjunction with setting the minLevel and maxLevel in prepareForOffline().
* @param minZoomAdjust An Integer specifying how far above the current layer you want to retrieve tiles
* @param maxZoomAdjust An Integer specifying how far below (closer to earth) the current layer you want to retrieve tiles
*/
layer.getMinMaxLOD = function(minZoomAdjust,maxZoomAdjust){
var zoom = {};
var map = layer.getMap();
var min = map.getLevel() + minZoomAdjust;
var max = map.getLevel() + maxZoomAdjust;
if(this._maxZoom != null && this._minZoom != null){
zoom.max = Math.min(this._maxZoom, max); //prevent errors by setting the tile layer floor
zoom.min = Math.max(this._minZoom, min); //prevent errors by setting the tile layer ceiling
}
else{
layer.getMinZoom(function(result){
zoom.min = Math.max(result, min); //prevent errors by setting the tile layer ceiling
});

layer.getMaxZoom(function(result){
zoom.max = Math.min(result, max); //prevent errors by setting the tile layer floor
});
}

return zoom;

};

/* internal methods */

/**
Expand Down Expand Up @@ -668,7 +723,7 @@ O.esri.Tiles.TilesCore = function(){
*/
this._getTiles = function(image,imageType,url,tileid,store,query){
store.retrieve(url, function(success, offlineTile)
{ console.log("TILE RETURN " + success + ", " + offlineTile)
{ console.log("TILE RETURN " + success + ", " + offlineTile.url)
/* when the .getTileUrl() callback is triggered we replace the temporary URL originally returned by the data:image url */
// search for the img with src="void:"+level+"-"+row+"-"+col and replace with actual url
image = query("img[src="+tileid+"]")[0];
Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tpk-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor - v2.2 - 2014-09-30
/*! offline-editor-js - v2.3 - 2014-10-13
* Copyright (c) 2014 Environmental Systems Research Institute, Inc.
* Apache License*/
/**
Expand Down

0 comments on commit 1039a76

Please sign in to comment.