Skip to content

Commit

Permalink
fix dynamic map layer ordering, basemap attribution in ie 10, update …
Browse files Browse the repository at this point in the history
…bower.json to more more correct
  • Loading branch information
patrickarlt committed Oct 30, 2013
1 parent e30aa33 commit 4aacb54
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 118 deletions.
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "esri-leaflet",
"version": "0.0.1",
"version": "0.0.1-rc.1",
"main": "dist/esri-leaflet.js",
"ignore": [
"**/.*",
"node_modules",
"components"
"examples"
"spec"
"vendor"
]
}
112 changes: 64 additions & 48 deletions dist/esri-leaflet-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Esri-Leaflet - v0.0.1 - 2013-10-10
/*! Esri-Leaflet - v0.0.1 - 2013-10-30
* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
* Apache License*/
(function (root, factory) {
Expand Down Expand Up @@ -2968,7 +2968,7 @@ L.esri.Mixins.identifiableLayer = {
TILES: {
Streets: {
urlTemplate: tileProtocol + "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/World_Street_Map?f=json",
attributionUrl: "https://static.arcgis.com/attribution/World_Street_Map",
options: {
minZoom: 1,
maxZoom: 19,
Expand All @@ -2978,7 +2978,7 @@ L.esri.Mixins.identifiableLayer = {
},
Topographic: {
urlTemplate: tileProtocol + "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/World_Topo_Map?f=json",
attributionUrl: "https://static.arcgis.com/attribution/World_Topo_Map",
options: {
minZoom: 1,
maxZoom: 19,
Expand All @@ -2988,7 +2988,7 @@ L.esri.Mixins.identifiableLayer = {
},
Oceans: {
urlTemplate: "https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/Ocean_Basemap?f=json",
attributionUrl: "https://static.arcgis.com/attribution/Ocean_Basemap",
options: {
minZoom: 1,
maxZoom: 16,
Expand Down Expand Up @@ -3089,7 +3089,7 @@ L.esri.Mixins.identifiableLayer = {

// if this basemap requires dynamic attribution set it up
if(config.attributionUrl){
var attributionUrl = L.esri.Util.cleanUrl(config.attributionUrl);
var attributionUrl = config.attributionUrl;
this._dynamicAttribution = true;
this._getAttributionData(attributionUrl);
}
Expand Down Expand Up @@ -3142,7 +3142,7 @@ L.esri.Mixins.identifiableLayer = {
},
_getAttributionData: function(url){
this.attributionBoundingBoxes = [];
L.esri.get(url, {}, this._processAttributionData, this);
L.esri.RequestHandlers.JSONP(url, {}, this._processAttributionData, this);
},
_processAttributionData: function(attributionData){
for (var c = 0; c < attributionData.contributors.length; c++) {
Expand Down Expand Up @@ -3351,13 +3351,14 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
includes: L.esri.Mixins.identifiableLayer,

defaultParams: {
format: 'png8',
format: 'png24',
transparent: true,
f: 'image',
bboxSR: 102100,
imageSR: 102100,
bboxSR: 4326,
imageSR: 3857,
layers: '',
opacity: 1
opacity: 1,
position: 'front'
},

initialize: function (url, options) {
Expand All @@ -3370,8 +3371,6 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
}
}

delete this._layerParams.token;

this._parseLayers();
this._parseLayerDefs();

Expand All @@ -3383,6 +3382,7 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
},

onAdd: function (map) {
this._bounds = map.getBounds();
this._map = map;

map.on("moveend", this._update, this);
Expand All @@ -3392,18 +3392,31 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
}

if (map.options.crs && map.options.crs.code) {
var sr = map.options.crs.code.split(":")[1];
this._layerParams.bboxSR = sr;
// spatial reference of the map
var sr = parseInt(map.options.crs.code.split(":")[1], 10);

// we want to output the image for the same spatial reference as the map
this._layerParams.imageSR = sr;

// we pass the bbox in 4326 (lat,lng)
this._layerParams.bboxSR = (sr === 3857) ? 4326 : sr;
}

this._update();
},

onRemove: function (map) {
map.getPanes().overlayPane.removeChild(this._image);
if(this._image){
map.getPanes().overlayPane.removeChild(this._image);
this._image = null;
}

if(this._newImage){
map.getPanes().overlayPane.removeChild(this._newImage);
this._newImage = null;
}

map.off("moveend", this._update, this);
map.off("moveend", L.Util.limitExecByInterval(this._update, 150, this), this);

if (map.options.zoomAnimation) {
map.off('zoomanim', this._animateZoom, this);
Expand All @@ -3414,10 +3427,8 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
var map = this._map,
image = this._image,
scale = map.getZoomScale(e.zoom),

nw = this._map.getBounds().getNorthWest(),
se = this._map.getBounds().getSouthEast(),

topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),
size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft),
origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale)));
Expand Down Expand Up @@ -3495,20 +3506,13 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
},

_getImageUrl: function () {
var bounds = this._map.getBounds(),
size = this._map.getSize(),
ne = this._map.options.crs.project(bounds._northEast),
sw = this._map.options.crs.project(bounds._southWest);
var size = this._map.getSize();

this._layerParams.bbox = [sw.x, sw.y, ne.x, ne.y].join(',');
this._layerParams.bbox = this._map.getBounds().toBBoxString();
this._layerParams.size = size.x + ',' + size.y;

var url = this.serviceUrl + 'export' + L.Util.getParamString(this._layerParams);

if (typeof this.options.token !== 'undefined'){
url = url + '&token=' + this.options.token;
}

return url;
},

Expand Down Expand Up @@ -3537,7 +3541,8 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
onselectstart: L.Util.falseFn,
onmousemove: L.Util.falseFn,
onload: L.Util.bind(this._onNewImageLoad, this),
src: this._getImageUrl()
src: this._getImageUrl(),
'data-bounds': this._map.getBounds().toBBoxString()
});
},

Expand All @@ -3551,28 +3556,39 @@ L.esri.DynamicMapLayer = L.ImageOverlay.extend({
},

_onNewImageLoad: function () {
var bounds = this._map.getBounds(),
nw = L.latLng(bounds._northEast.lat, bounds._southWest.lng),
se = L.latLng(bounds._southWest.lat, bounds._northEast.lng);

var topLeft = this._map.latLngToLayerPoint(nw),
size = this._map.latLngToLayerPoint(se)._subtract(topLeft);
L.DomUtil.setPosition(this._newImage, topLeft);
this._newImage.style.width = size.x + 'px';
this._newImage.style.height = size.y + 'px';

if (this._image == null) {
this._map._panes.overlayPane.appendChild(this._newImage);
} else {
this._map._panes.overlayPane.insertBefore(this._newImage,this._image);
this._map._panes.overlayPane.removeChild(this._image);
}
if(this._newImage){
var bbox = this._newImage['data-bounds'].split(','),
bounds = L.latLngBounds([[bbox[1],bbox[0]], [bbox[3],bbox[2]] ]),
nw = L.latLng(bounds._northEast.lat, bounds._southWest.lng),
se = L.latLng(bounds._southWest.lat, bounds._northEast.lng),
topLeft = this._map.latLngToLayerPoint(nw),
size = this._map.latLngToLayerPoint(se)._subtract(topLeft);

this._image = this._newImage;
this._newImage = null;
this.fire('load');
}
L.DomUtil.setPosition(this._newImage, topLeft);

this._newImage.style.width = size.x + 'px';
this._newImage.style.height = size.y + 'px';

if(this.options.zindex){
this._newImage.style.zIndex = this.options.zindex;
}

if (this._image == null) {
if(this.options.position === 'back' && this._map._panes.overlayPane.children.length){
this._map._panes.overlayPane.insertBefore(this._newImage,this._map._panes.overlayPane.children[0]);
} else {
this._map._panes.overlayPane.appendChild(this._newImage);
}
} else {
this._map._panes.overlayPane.insertBefore(this._newImage,this._image);
this._map._panes.overlayPane.removeChild(this._image);
}

this._image = this._newImage;
this._newImage = null;
this.fire('load');
}
}
});

L.esri.dynamicMapLayer = function (url, options) {
Expand Down
6 changes: 3 additions & 3 deletions dist/esri-leaflet.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/extras/clustered-feature-layer-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Esri-Leaflet - v0.0.1 - 2013-10-10
/*! Esri-Leaflet - v0.0.1 - 2013-10-30
* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
* Apache License*/
/* globals Terraformer, L */
Expand Down
2 changes: 1 addition & 1 deletion dist/extras/clustered-feature-layer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions dist/extras/esri-basemaps-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Esri-Leaflet - v0.0.1 - 2013-10-10
/*! Esri-Leaflet - v0.0.1 - 2013-10-30
* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
* Apache License*/
/* globals L */
Expand Down Expand Up @@ -357,7 +357,7 @@ L.esri.Mixins.identifiableLayer = {
TILES: {
Streets: {
urlTemplate: tileProtocol + "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/World_Street_Map?f=json",
attributionUrl: "https://static.arcgis.com/attribution/World_Street_Map",
options: {
minZoom: 1,
maxZoom: 19,
Expand All @@ -367,7 +367,7 @@ L.esri.Mixins.identifiableLayer = {
},
Topographic: {
urlTemplate: tileProtocol + "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/World_Topo_Map?f=json",
attributionUrl: "https://static.arcgis.com/attribution/World_Topo_Map",
options: {
minZoom: 1,
maxZoom: 19,
Expand All @@ -377,7 +377,7 @@ L.esri.Mixins.identifiableLayer = {
},
Oceans: {
urlTemplate: "https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}/",
attributionUrl: "https://static.arcgis.com/attribution/Ocean_Basemap?f=json",
attributionUrl: "https://static.arcgis.com/attribution/Ocean_Basemap",
options: {
minZoom: 1,
maxZoom: 16,
Expand Down Expand Up @@ -478,7 +478,7 @@ L.esri.Mixins.identifiableLayer = {

// if this basemap requires dynamic attribution set it up
if(config.attributionUrl){
var attributionUrl = L.esri.Util.cleanUrl(config.attributionUrl);
var attributionUrl = config.attributionUrl;
this._dynamicAttribution = true;
this._getAttributionData(attributionUrl);
}
Expand Down Expand Up @@ -531,7 +531,7 @@ L.esri.Mixins.identifiableLayer = {
},
_getAttributionData: function(url){
this.attributionBoundingBoxes = [];
L.esri.get(url, {}, this._processAttributionData, this);
L.esri.RequestHandlers.JSONP(url, {}, this._processAttributionData, this);
},
_processAttributionData: function(attributionData){
for (var c = 0; c < attributionData.contributors.length; c++) {
Expand Down
Loading

0 comments on commit 4aacb54

Please sign in to comment.