Enable ProjectionLike on getGetFeatureInfoUrl

This commit is contained in:
Peter Robins
2014-07-12 08:47:30 +00:00
parent 9db936fe87
commit 7b32b8e561
2 changed files with 7 additions and 6 deletions

View File

@@ -18,8 +18,6 @@ var view = new ol.View({
zoom: 1 zoom: 1
}); });
var viewProjection = view.getProjection();
var map = new ol.Map({ var map = new ol.Map({
layers: [wmsLayer], layers: [wmsLayer],
target: 'map', target: 'map',
@@ -30,7 +28,7 @@ map.on('singleclick', function(evt) {
document.getElementById('info').innerHTML = ''; document.getElementById('info').innerHTML = '';
var viewResolution = /** @type {number} */ (view.getResolution()); var viewResolution = /** @type {number} */ (view.getResolution());
var url = wmsSource.getGetFeatureInfoUrl( var url = wmsSource.getGetFeatureInfoUrl(
evt.coordinate, viewResolution, viewProjection, evt.coordinate, viewResolution, 'EPSG:3857',
{'INFO_FORMAT': 'text/html'}); {'INFO_FORMAT': 'text/html'});
if (url) { if (url) {
document.getElementById('info').innerHTML = document.getElementById('info').innerHTML =

View File

@@ -14,6 +14,7 @@ goog.require('ol');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.source.TileImage'); goog.require('ol.source.TileImage');
goog.require('ol.source.wms'); goog.require('ol.source.wms');
goog.require('ol.source.wms.ServerType'); goog.require('ol.source.wms.ServerType');
@@ -121,7 +122,7 @@ goog.inherits(ol.source.TileWMS, ol.source.TileImage);
* constructed. * constructed.
* @param {ol.Coordinate} coordinate Coordinate. * @param {ol.Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution. * @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.ProjectionLike} projection Projection.
* @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should * @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified * be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be * in the `LAYERS` parameter will be used. `VERSION` should not be
@@ -139,9 +140,11 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
return undefined; return undefined;
} }
var projectionObj = ol.proj.get(projection);
var tileGrid = this.getTileGrid(); var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) { if (goog.isNull(tileGrid)) {
tileGrid = this.getTileGridForProjection(projection); tileGrid = this.getTileGridForProjection(projectionObj);
} }
var tileCoord = tileGrid.getTileCoordForCoordAndResolution( var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
@@ -185,7 +188,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
goog.object.set(baseParams, this.v13_ ? 'J' : 'Y', y); goog.object.set(baseParams, this.v13_ ? 'J' : 'Y', y);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent, return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
pixelRatio, projection, baseParams); pixelRatio, projectionObj, baseParams);
}; };