Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap x feature for pull request #198

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Once you have the development dependencies installed, we can use our predefined
* **grunt test:unit**. Executes only the karma unitary tests.
* **grunt test:e2e**. Executes only the protractor e2e tests.
* **grunt coverage**. Generates a "coverage" folder with an [istanbul](https://github.com/gotwarlost/istanbul) report of wich part of the code is covered by the actual tests.
* **grunt**. The default task watches for project files changes and when a change is detected, tries to build the library file passing the jshint filter and the tests. Let's see an example:
* **grunt**. The default task watches for project files changes and when a change is detected, tries to build the library file passing the jshint filter and the tests. Let's see an example:

```
$ grunt
Expand All @@ -139,7 +139,7 @@ Running "jshint:grunt" (jshint) task
Running "concat:dist" (concat) task
File "dist/angular-openlayers-directive.js" created.

Running "ngmin:directives" (ngmin) task
Running "ngAnnotate" (ngAnnotate) task
ngminifying dist/angular-openlayers-directive.js

Running "uglify:dist" (uglify) task
Expand Down
60 changes: 40 additions & 20 deletions src/services/olHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
oSource = new ol.source.XYZ({
url: url,
attributions: createAttribution(source),
tilePixelRatio: pixelRatio > 1 ? 2 : 1
tilePixelRatio: pixelRatio > 1 ? 2 : 1,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'ImageWMS':
Expand All @@ -219,7 +220,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
url: source.url,
attributions: createAttribution(source),
crossOrigin: (typeof source.crossOrigin === 'undefined') ? 'anonymous' : source.crossOrigin,
params: source.params
params: source.params,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;

Expand All @@ -232,7 +234,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
var wmsConfiguration = {
crossOrigin: (typeof source.crossOrigin === 'undefined') ? 'anonymous' : source.crossOrigin,
params: source.params,
attributions: createAttribution(source)
attributions: createAttribution(source),
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
};

if (source.url) {
Expand Down Expand Up @@ -264,7 +267,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
origin: source.tileGrid.origin,
resolutions: source.tileGrid.resolutions,
matrixIds: source.tileGrid.matrixIds
})
}),
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
};

if (isDefined(source.url)) {
Expand All @@ -280,7 +284,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

case 'OSM':
oSource = new ol.source.OSM({
attributions: createAttribution(source)
attributions: createAttribution(source),
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});

if (source.url) {
Expand All @@ -298,7 +303,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
key: source.key,
attributions: createAttribution(source),
imagerySet: source.imagerySet ? source.imagerySet : bingImagerySets[0],
culture: source.culture
culture: source.culture,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
};

if (source.maxZoom) {
Expand All @@ -316,7 +322,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

oSource = new ol.source.MapQuest({
attributions: createAttribution(source),
layer: source.layer
layer: source.layer,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});

break;
Expand All @@ -332,7 +339,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

oSource = new ol.source.XYZ({
attributions: createAttribution(source),
url: _url
url: _url,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});

break;
Expand All @@ -347,7 +355,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
if (isDefined(source.url)) {
oSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: source.url
url: source.url,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
} else {
oSource = new ol.source.Vector();
Expand Down Expand Up @@ -382,7 +391,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
}).error(function(response) {
$log(response);
});
}
},
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
}
break;
Expand All @@ -396,19 +406,22 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
if (source.url) {
oSource = new ol.source.Vector({
format: new ol.format.TopoJSON(),
url: source.url
url: source.url,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
} else {
oSource = new ol.source.Vector(angular.extend(source.topojson, {
format: new ol.format.TopoJSON()
format: new ol.format.TopoJSON(),
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
}));
}
break;
case 'TileJSON':
oSource = new ol.source.TileJSON({
url: source.url,
attributions: createAttribution(source),
crossOrigin: 'anonymous'
crossOrigin: 'anonymous',
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;

Expand All @@ -423,7 +436,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
format: source.format,
tileGrid: new ol.tilegrid.createXYZ({
maxZoom: source.maxZoom || 19
})
}),
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;

Expand Down Expand Up @@ -452,7 +466,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
var url = source.url + z + '/' + x + '/' + y + '.png';

return url;
}
},
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'TileImage':
Expand All @@ -472,7 +487,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
.replace('{x}', x.toString())
.replace('{y}', y.toString());
return url;
}
},
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'KML':
Expand All @@ -481,7 +497,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
url: source.url,
format: new ol.format.KML(),
radius: source.radius,
extractStyles: extractStyles
extractStyles: extractStyles,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'Stamen':
Expand All @@ -490,7 +507,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
return;
}
oSource = new ol.source.Stamen({
layer: source.layer
layer: source.layer,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'ImageStatic':
Expand All @@ -505,7 +523,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
imageSize: source.imageSize,
projection: projection,
imageExtent: projection.getExtent(),
imageLoadFunction: source.imageLoadFunction
imageLoadFunction: source.imageLoadFunction,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
case 'XYZ':
Expand All @@ -516,7 +535,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
url: source.url,
attributions: createAttribution(source),
minZoom: source.minZoom,
maxZoom: source.maxZoom
maxZoom: source.maxZoom,
wrapX: (source.wrapX === undefined) ? 1 : source.wrapX
});
break;
}
Expand Down