[mapguide-commits] r9545 - sandbox/jng/tiling_v3/Doc/samples/ol2samples/hybrid
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jun 12 06:40:15 PDT 2019
Author: jng
Date: 2019-06-12 06:40:15 -0700 (Wed, 12 Jun 2019)
New Revision: 9545
Modified:
sandbox/jng/tiling_v3/Doc/samples/ol2samples/hybrid/index.html
Log:
Fix default tile grid in hybrid sample
Modified: sandbox/jng/tiling_v3/Doc/samples/ol2samples/hybrid/index.html
===================================================================
--- sandbox/jng/tiling_v3/Doc/samples/ol2samples/hybrid/index.html 2019-06-12 13:24:10 UTC (rev 9544)
+++ sandbox/jng/tiling_v3/Doc/samples/ol2samples/hybrid/index.html 2019-06-12 13:40:15 UTC (rev 9545)
@@ -121,7 +121,7 @@
/**
* A helper view model class to encapsulate all map-related
- * view satte
+ * view state
*/
function MapViewModel(el, rtMapInfo, size) {
var _this = this;
@@ -176,6 +176,7 @@
var zOrigin = _this.finiteScales.length - 1;
var resolutions = new Array(_this.finiteScales.length);
if (rtMapInfo.RuntimeMap.TileSetProvider == "XYZ") {
+ $("scale-el").hide(); //Not applicable for XYZ
for (var i = 0; i < rtMapInfo.RuntimeMap.Group.length; i++) {
var group = rtMapInfo.RuntimeMap.Group[i];
if (group.Type != 2 && group.Type != 3) { //BaseMap or LinkedTileSet
@@ -190,12 +191,13 @@
html: '<img src="../../localized/PoweredBy_en.gif" title="Powered by MapGuide" />'
})
],
- tileUrlFunction: getTileUrlFunctionForGroup(resourceId, group.Name, zOrigin)
+ url: getTileUrlTemplate(resourceId, group.Name, true)
})
})
);
}
} else {
+ $("scale-el").show();
var inPerUnit = 39.37 * metersPerUnit;
for (var i = 0; i < _this.finiteScales.length; ++i) {
resolutions[i] = _this.finiteScales[i] / inPerUnit / dpi;
@@ -287,9 +289,19 @@
}
*/
if (resolutions.length == 0) {
- _this.view = new ol.View({
- projection: projection
- });
+ if (rtMapInfo.RuntimeMap.TileSetProvider == "XYZ") {
+ var center = ol.extent.getCenter(extent);
+ _this.view = new ol.View({
+ center: ol.proj.transform(center, 'EPSG:4326', 'EPSG:3857'),
+ minZoom: 10,
+ maxZoom: 19,
+ zoom: 12
+ });
+ } else {
+ _this.view = new ol.View({
+ projection: projection
+ });
+ }
} else {
_this.view = new ol.View({
projection: projection,
@@ -323,14 +335,24 @@
_this.legend.update();
}
- function getTileUrlFunctionForGroup(resourceId, groupName, zOrigin) {
+ function getTileUrlTemplate(resourceId, groupName, isXYZ) {
var urlTemplate = mapAgentUrl
- + "?OPERATION=GETTILEIMAGE&VERSION=1.2.0&USERNAME=Anonymous"
+ + "?OPERATION=GETTILEIMAGE"
+ + "&VERSION=1.2.0"
+ + "&USERNAME=Anonymous"
+ "&MAPDEFINITION=" + resourceId
- + "&BASEMAPLAYERGROUPNAME=" + groupName
- + "&TILEROW={x}"
- + "&TILECOL={y}"
- + "&SCALEINDEX={z}";
+ + "&BASEMAPLAYERGROUPNAME=" + groupName;
+ if (isXYZ) {
+ urlTemplate += "&TILEROW={x}&TILECOL={y}";
+ } else {
+ urlTemplate += "&TILEROW={y}&TILECOL={x}";
+ }
+ urlTemplate += "&SCALEINDEX={z}";
+ return urlTemplate;
+ }
+
+ function getTileUrlFunctionForGroup(resourceId, groupName, zOrigin) {
+ var urlTemplate = getTileUrlTemplate(resourceId, groupName, false);
return function (tileCoord) {
return urlTemplate
.replace('{z}', (zOrigin - tileCoord[0]).toString())
@@ -390,7 +412,7 @@
</div>
<div class="clearfix"></div>
<div class="alert alert-info">
- <p>Scale: 1:<span id="scale"></span></p>
+ <p id="scale-el">Scale: 1:<span id="scale"></span></p>
<p>JSON payload for CREATERUNTIMEMAP is: <span id="jsonSize"></span> characters</p>
<p>Icon format is: <span id="iconFormat"></span></p>
<p id="mapName"></p>
More information about the mapguide-commits
mailing list