diff --git a/mapea-js/package.json b/mapea-js/package.json index 0219fa722..3e1b7f55a 100644 --- a/mapea-js/package.json +++ b/mapea-js/package.json @@ -1,6 +1,6 @@ { "name": "mapea", - "version": "6.5.0", + "version": "6.6.0", "description": "Herramienta para desarrollo de mapas interactivos de forma sencilla", "keywords": [ "map", diff --git a/mapea-js/pom.xml b/mapea-js/pom.xml index 2c32ccec4..3b772e85b 100644 --- a/mapea-js/pom.xml +++ b/mapea-js/pom.xml @@ -6,7 +6,7 @@ es.juntadeandalucia.mapea mapea-parent - 6.5.0 + 6.6.0 ../mapea-parent/pom.xml diff --git a/mapea-js/src/facade/assets/css/popup.css b/mapea-js/src/facade/assets/css/popup.css index 8cdf504b3..aa31948dc 100644 --- a/mapea-js/src/facade/assets/css/popup.css +++ b/mapea-js/src/facade/assets/css/popup.css @@ -398,7 +398,7 @@ } .m-popup>div.m-content>div.m-header>a.m-popup-closer:after { - content: "\e919"; + content: "\2716"; } .m-popup.m-full.m-has-tabs>div.m-content>div.m-header>a.m-popup-closer { diff --git a/mapea-js/src/facade/js/Map.js b/mapea-js/src/facade/js/Map.js index bed498cd7..676c4e081 100644 --- a/mapea-js/src/facade/js/Map.js +++ b/mapea-js/src/facade/js/Map.js @@ -198,6 +198,11 @@ class Map extends Base { */ this.ticket_ = null; + // ticket + if (!isNullOrEmpty(params.ticket)) { + this.setTicket(params.ticket); + } + // adds class to the container params.container.classList.add('m-mapea-container'); if (!isNullOrEmpty(params.bgColorContainer)) { @@ -334,11 +339,6 @@ class Map extends Base { this.addLabel(params.label); } - // ticket - if (!isNullOrEmpty(params.ticket)) { - this.setTicket(params.ticket); - } - // initial zoom if (isNullOrEmpty(params.bbox) && isNullOrEmpty(params.zoom) && isNullOrEmpty(params.center)) { this.zoomToMaxExtent(true); diff --git a/mapea-js/src/facade/js/layer/GeoJSON.js b/mapea-js/src/facade/js/layer/GeoJSON.js index 649b675fa..e37b92fae 100644 --- a/mapea-js/src/facade/js/layer/GeoJSON.js +++ b/mapea-js/src/facade/js/layer/GeoJSON.js @@ -121,12 +121,25 @@ class GeoJSON extends LayerVector { if (obj instanceof GeoJSON) { equals = this.name === obj.name; equals = equals && (this.extract === obj.extract); + equals = equals && (this.template === obj.template); equals = equals && (this.id === obj.id); } return equals; } + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + /** * Sets the source of the layer, in GeoJSON format * diff --git a/mapea-js/src/facade/js/layer/KML.js b/mapea-js/src/facade/js/layer/KML.js index 423321ae6..5922693f8 100644 --- a/mapea-js/src/facade/js/layer/KML.js +++ b/mapea-js/src/facade/js/layer/KML.js @@ -57,6 +57,9 @@ class KML extends LayerVector { // extract this.extract = parameters.extract; + // template + this.template = parameters.template; + // options this.options = options; @@ -98,6 +101,17 @@ class KML extends LayerVector { } } + /** + * 'template' the features properties + */ + get template() { + return this.getImpl().template; + } + + set template(newTemplate) { + this.getImpl().template = newTemplate; + } + /** * 'options' the layer options */ @@ -109,6 +123,18 @@ class KML extends LayerVector { this.getImpl().options = newOptions; } + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + /** * Checks if an object is equal to this layer. Two KML layers are equal if both of them * are instances of KML, and have the same 'name' and 'extract' attributes @@ -124,6 +150,7 @@ class KML extends LayerVector { equals = (this.url === obj.url); equals = equals && (this.name === obj.name); equals = equals && (this.extract === obj.extract); + equals = equals && (this.template === obj.template); equals = equals && (this.id === obj.id); } diff --git a/mapea-js/src/facade/js/layer/LayerGroup.js b/mapea-js/src/facade/js/layer/LayerGroup.js index 351ec2c06..54b8292d9 100644 --- a/mapea-js/src/facade/js/layer/LayerGroup.js +++ b/mapea-js/src/facade/js/layer/LayerGroup.js @@ -192,7 +192,7 @@ class LayerGroup extends MObject { if (isNullOrEmpty(index)) { this.children_.unshift(child); } else { - this.children_.splice(index - 1, 0, child); + this.children_.splice(index, 0, child); zIndex = this.getZIndex() + index; } if (child instanceof LayerGroup) { diff --git a/mapea-js/src/facade/js/layer/MVT.js b/mapea-js/src/facade/js/layer/MVT.js index 24445bf42..e10dcd4cf 100644 --- a/mapea-js/src/facade/js/layer/MVT.js +++ b/mapea-js/src/facade/js/layer/MVT.js @@ -55,6 +55,20 @@ class MVT extends Vector { } } + /** + * This function sets + * the tileLoadFunction + * On the implementation + * + * @function + * @public + * @param {Function} func Function to override + * @api + */ + setTileLoadFunction(func){ + this.getImpl().setTileLoadFunction(func); + } + /** * This method calculates the maxExtent of this layer: * 1. Check if the user specified a maxExtent parameter diff --git a/mapea-js/src/facade/js/layer/Mapbox.js b/mapea-js/src/facade/js/layer/Mapbox.js index 978d327fc..f996c7b54 100644 --- a/mapea-js/src/facade/js/layer/Mapbox.js +++ b/mapea-js/src/facade/js/layer/Mapbox.js @@ -132,6 +132,44 @@ class Mapbox extends LayerBase { } } + /** + * This function sets + * the tileLoadFunction + * On the implementation + * + * @function + * @public + * @param {Function} func Function to override + * @api + */ + setTileLoadFunction(func){ + this.getImpl().setTileLoadFunction(func); + } + + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + + /** + * Sets the name of the layer + * + * @function + * @public + * @param {String} newName Name + * @api + */ + setName(newName) { + this.getImpl().setName(newName); + } + /** * Checks if an object is equal to this layer, which means that it is a Mapbox Layer instance and * has the same url, name and options. diff --git a/mapea-js/src/facade/js/layer/OSM.js b/mapea-js/src/facade/js/layer/OSM.js index a1e834216..c2e1d8ac1 100644 --- a/mapea-js/src/facade/js/layer/OSM.js +++ b/mapea-js/src/facade/js/layer/OSM.js @@ -97,6 +97,20 @@ class OSM extends LayerBase { } } + /** + * This function sets + * the tileLoadFunction + * On the implementation + * + * @function + * @public + * @param {Function} func Function to override + * @api + */ + setTileLoadFunction(func){ + this.getImpl().setTileLoadFunction(func); + } + /** * This function checks if an object is equals * to this layer diff --git a/mapea-js/src/facade/js/layer/Vector.js b/mapea-js/src/facade/js/layer/Vector.js index 8b5846eb0..5fe5217c4 100644 --- a/mapea-js/src/facade/js/layer/Vector.js +++ b/mapea-js/src/facade/js/layer/Vector.js @@ -46,6 +46,9 @@ class Vector extends LayerBase { this.extract = true; // by default } + // template + this.template = parameters.template; + /** * Style of the layer * @private @@ -99,6 +102,17 @@ class Vector extends LayerBase { } } + /** + * 'template' the features properties + */ + get template() { + return this.getImpl().template; + } + + set template(newTemplate) { + this.getImpl().template = newTemplate; + } + /** * Adds features to layer. Only features that are not already in the layer * will be added. Two features are equal if the have the same id. diff --git a/mapea-js/src/facade/js/layer/WFS.js b/mapea-js/src/facade/js/layer/WFS.js index 8102678ee..525539eff 100644 --- a/mapea-js/src/facade/js/layer/WFS.js +++ b/mapea-js/src/facade/js/layer/WFS.js @@ -65,6 +65,9 @@ class WFS extends Vector { // extract this.extract = parameters.extract; + + // template + this.template = parameters.template; } /** @@ -164,6 +167,56 @@ class WFS extends Vector { this.getImpl().version = '1.0.0'; // default value } } + + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + + /** + * Sets the name of the layer + * + * @function + * @public + * @param {String} newName Name + * @api + */ + setName(newName) { + this.getImpl().setName(newName); + } + + /** + * Sets the namespace of the layer + * + * @function + * @public + * @param {String} newNamespace Namespace + * @api + */ + setNamespace(newNamespace) { + this.getImpl().setNamespace(newNamespace); + } + + /** + * Sets the geometry of the layer + * + * @function + * @public + * @param {String} newGeometry Geometry + * @api + */ + setGeometry(newGeometry) { + this.geometry = newGeometry; + this.getImpl().setGeometry(newGeometry); + } + /** * Sets a CQL string to apply to the layer. A new query will be made to the WFS server. * @param {String} cql CQL to apply diff --git a/mapea-js/src/facade/js/layer/WMS.js b/mapea-js/src/facade/js/layer/WMS.js index 547733f9b..5565b8f69 100644 --- a/mapea-js/src/facade/js/layer/WMS.js +++ b/mapea-js/src/facade/js/layer/WMS.js @@ -50,7 +50,9 @@ class WMS extends LayerBase { this.legend = parameters.legend; // cql - this.cql = parameters.cql; + if (vendorOptions?.cql) { + this.cql = vendorOptions.cql; + } // version this.version = parameters.version; @@ -181,6 +183,44 @@ class WMS extends LayerBase { this.getImpl().options = newOptions; } + /** + * This function sets + * the tileLoadFunction + * On the implementation + * + * @function + * @public + * @param {Function} func Function to override + * @api + */ + setTileLoadFunction(func){ + this.getImpl().setTileLoadFunction(func); + } + + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + + /** + * Sets the name of the layer + * + * @function + * @public + * @param {String} newName Name + * @api + */ + setName(newName) { + this.getImpl().setName(newName); + } + /** * Calculates the maxExtent of this layer, being the first value found in this order: * 1. checks if the user specified a maxExtent parameter for the layer. diff --git a/mapea-js/src/facade/js/layer/WMTS.js b/mapea-js/src/facade/js/layer/WMTS.js index 1eebbf1a7..2f61c6afe 100644 --- a/mapea-js/src/facade/js/layer/WMTS.js +++ b/mapea-js/src/facade/js/layer/WMTS.js @@ -112,6 +112,44 @@ class WMTS extends LayerBase { this.getImpl().options = newOptions; } + /** + * This function sets + * the tileLoadFunction + * On the implementation + * + * @function + * @public + * @param {Function} func Function to override + * @api + */ + setTileLoadFunction(func){ + this.getImpl().setTileLoadFunction(func); + } + + /** + * Sets the url of the layer + * + * @function + * @public + * @param {String} newURL URL + * @api + */ + setURL(newURL) { + this.getImpl().setURL(newURL); + } + + /** + * Sets the name of the layer + * + * @function + * @public + * @param {String} newName Name + * @api + */ + setName(newName) { + this.getImpl().setName(newName); + } + /** * Creates a Promise which will be * resolved when the GetCapabilities request is retrieved diff --git a/mapea-js/src/facade/js/parameter/geojson.js b/mapea-js/src/facade/js/parameter/geojson.js index 31c9958a7..3e6c4f93f 100644 --- a/mapea-js/src/facade/js/parameter/geojson.js +++ b/mapea-js/src/facade/js/parameter/geojson.js @@ -91,6 +91,12 @@ const geojson = (userParameters) => { attr: 'extract', })(GEOJSON_REGEX, 3); + const template = getParameter({ + parameter: userParam, + type: 'boolean', + attr: 'template', + })(GEOJSON_REGEX, 3); + const style = getParameter({ parameter: userParam, type: 'string', @@ -103,6 +109,7 @@ const geojson = (userParameters) => { url, extract, style, + template, }; }); diff --git a/mapea-js/src/facade/js/parameter/kml.js b/mapea-js/src/facade/js/parameter/kml.js index 207be5433..79cda7841 100644 --- a/mapea-js/src/facade/js/parameter/kml.js +++ b/mapea-js/src/facade/js/parameter/kml.js @@ -105,6 +105,12 @@ const kml = (userParamer) => { attr: 'extract', }); + const template = getParameter({ + parameter: userParam, + type: 'string', + attr: 'template', + }); + const label = getParameter({ parameter: userParam, type: 'boolean_eql', @@ -118,6 +124,7 @@ const kml = (userParamer) => { url: url(REGEXP_KML, 2) + url(REGEXP_KML, 3), extract: extract(REGEXP_KML, 4), label: label(REGEXP_KML, 5), + template: template(REGEXP_KML, 6), }; } else { layerObj = { @@ -126,6 +133,7 @@ const kml = (userParamer) => { url: url(REGEXP_KML), extract: extract(REGEXP_KML), label: label(REGEXP_KML), + template: template(REGEXP_KML), }; } diff --git a/mapea-js/src/facade/js/util/Utils.js b/mapea-js/src/facade/js/util/Utils.js index 6605cd774..69cd91741 100644 --- a/mapea-js/src/facade/js/util/Utils.js +++ b/mapea-js/src/facade/js/util/Utils.js @@ -7,6 +7,16 @@ import reproj from 'impl/util/reprojection'; import getImplWMTSCapabilities from 'impl/util/GetCapabilities.js'; import { INCHES_PER_UNIT, DOTS_PER_INCH } from '../units.js'; import * as WKT from '../geom/WKT.js'; + +/** + * + * @function + * @api + */ +export const getFeaturesExtent = (features, projectionCode) => { + return M.impl.utils.getFeaturesExtent(features, projectionCode); +}; + /** * * @function @@ -1121,7 +1131,7 @@ export const isDynamic = (obj) => { * @const * @type {string} */ -let dynamicLegend = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKC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g+AHi6uKk6CIl/i8ptIj14Lgf7+497t4BQr3MNKtrHNB020wl4mImuyoGXhFECGH0ol9mljEnSUl0HF/38PH1LsazOp/7c/SoOYsBPpF4lhmmTbxBPL1pG5z3iSOsKKvE58RjJl2Q+JHrisdvnAsuCzwzYqZT88QRYrHQxkobs6KpEU8RR1VNp3wh47HKeYuzVq6y5j35C8M5fWWZ6zSHkcAiliBBhIIqSijDRoxWnRQLKdqPd/APuX6JXAq5SmDkWEAFGmTXD/4Hv7u18pMTXlI4DnS/OM7HCBDYBRo1x/k+dpzGCeB/Bq70lr9SB2Y+Sa+1tOgR0LcNXFy3NGUPuNwBBp8M2ZRdyU9TyOeB9zP6piwwcAuE1rzemvs4fQDS1FXyBjg4BEYLlL3e4d3B9t7+PdPs7wcKRXJ9HBxvdAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+cICgwaEtLWWMgAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAQklEQVQ4y2P8z8yAFZSwfMEqvhO7coa441ZYxZkYaAxGLRi1gHLAsvXOa6wSjXuEsYrzCsVjFa9VezIaB6MW0AgAACUUCncamxS/AAAAAElFTkSuQmCC'; /** * This functions sets the dynamic legend constant diff --git a/mapea-js/src/impl/ol/Map.js b/mapea-js/src/impl/ol/Map.js index ff7f17fb2..ca07f241f 100644 --- a/mapea-js/src/impl/ol/Map.js +++ b/mapea-js/src/impl/ol/Map.js @@ -581,6 +581,10 @@ class Map extends MObject { if (!isNullOrEmpty(filterLayer.extract)) { layerMatched = (layerMatched && (filterLayer.extract === kmlLayer.extract)); } + // template + if (!isNullOrEmpty(filterLayer.template)) { + layerMatched = (layerMatched && (filterLayer.template === kmlLayer.template)); + } } else { layerMatched = false; } diff --git a/mapea-js/src/impl/ol/format/wmc/WMC110.js b/mapea-js/src/impl/ol/format/wmc/WMC110.js index 25a76769a..c546eb55f 100644 --- a/mapea-js/src/impl/ol/format/wmc/WMC110.js +++ b/mapea-js/src/impl/ol/format/wmc/WMC110.js @@ -102,7 +102,8 @@ class WMC110 extends XML { } if (!isNullOrEmpty(group)) { - group.addChild(layer, parseInt(groupOrder, 10)); + // -1 To match the addChild parameter (starts from 0) + group.addChild(layer, parseInt(groupOrder - 1, 10)); } else { if (isNullOrEmpty(context.layers)) { context.layers = []; diff --git a/mapea-js/src/impl/ol/layer/Draw.js b/mapea-js/src/impl/ol/layer/Draw.js index 5ba167428..f2b579dcc 100644 --- a/mapea-js/src/impl/ol/layer/Draw.js +++ b/mapea-js/src/impl/ol/layer/Draw.js @@ -70,7 +70,6 @@ class Draw extends Layer { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); this.ol3Layer = new OLLayerVector({ source: new OLSourceVector({}), @@ -101,6 +100,7 @@ class Draw extends Layer { } const olMap = this.map.getMapImpl(); olMap.addLayer(this.ol3Layer); + this.fire(EventType.ADDED_TO_MAP); } /** diff --git a/mapea-js/src/impl/ol/layer/GeoJSON.js b/mapea-js/src/impl/ol/layer/GeoJSON.js index 426445e06..f7da72d1e 100644 --- a/mapea-js/src/impl/ol/layer/GeoJSON.js +++ b/mapea-js/src/impl/ol/layer/GeoJSON.js @@ -131,6 +131,32 @@ class GeoJSON extends Vector { this.updateSource_(); } + /** + * Updates the layer with the new URL + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + this.loader_.url_ = this.url + this.loadFeaturesPromise_ = undefined; + this.updateSource_(); + } + + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + /** * This function sets the map object of the layer * @@ -235,6 +261,7 @@ class GeoJSON extends Vector { if (obj instanceof GeoJSON) { equals = equals && (this.name === obj.name); equals = equals && (this.extract === obj.extract); + equals = equals && (this.template === obj.template); } return equals; } diff --git a/mapea-js/src/impl/ol/layer/KML.js b/mapea-js/src/impl/ol/layer/KML.js index 0acab0e37..ceba11794 100644 --- a/mapea-js/src/impl/ol/layer/KML.js +++ b/mapea-js/src/impl/ol/layer/KML.js @@ -103,7 +103,6 @@ class KML extends Vector { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); map.on(EventType.CHANGE_PROJ, this.setProjection_.bind(this), this); this.formater_ = new FormatKML({ label: this.label_, @@ -121,6 +120,8 @@ class KML extends Vector { } const olMap = this.map.getMapImpl(); olMap.addLayer(this.ol3Layer); + this.fire(EventType.ADDED_TO_MAP); + this.facadeVector_?.fire(EventType.ADDED_TO_MAP); } /** @@ -140,7 +141,9 @@ class KML extends Vector { const featureDesc = feature.getAttribute('description'); const featureCoord = feature.getImpl().getOLFeature().getGeometry().getFirstCoordinate(); - const htmlAsText = compileTemplate(popupKMLTemplate, { + const popup_template = !isNullOrEmpty(this.template) ? this.template : popupKMLTemplate; + + const htmlAsText = compileTemplate(popup_template, { vars: { name: featureName, desc: featureDesc, @@ -179,15 +182,49 @@ class KML extends Vector { } } + /** + * Removes and creates the ol3layer + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + const olMap = this.map.getMapImpl(); + + if (!isNullOrEmpty(this.ol3Layer)) { + olMap.removeLayer(this.ol3Layer); + this.ol3Layer = null; + } + + this.formater_ = new FormatKML({ + label: this.label_, + }); + this.loader_ = new LoaderKML(this.map, this.url, this.formater_); + this.ol3Layer = new OLLayerVector(extend({}, this.vendorOptions_, true)); + this.updateSource_(true); + // sets its visibility if it is in range + if (this.options.visibility !== false) { + this.setVisible(this.inRange()); + } + // sets its z-index + if (this.zIndex_ !== null) { + this.setZIndex(this.zIndex_); + } + + olMap.addLayer(this.ol3Layer); + } + /** * This function sets the map object of the layer * * @private * @function */ - updateSource_() { + updateSource_(force) { if (isNullOrEmpty(this.vendorOptions_.source)) { - this.requestFeatures_().then((response) => { + this.requestFeatures_(force).then((response) => { this.ol3Layer.setSource(new OLSourceVector({ loader: () => { const screenOverlay = response.screenOverlay; @@ -206,6 +243,18 @@ class KML extends Vector { } } + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + /** * Sets the screen overlay image for this KML * @@ -260,8 +309,8 @@ class KML extends Vector { * @private * @function */ - requestFeatures_() { - if (isNullOrEmpty(this.loadFeaturesPromise_)) { + requestFeatures_(force) { + if (force || isNullOrEmpty(this.loadFeaturesPromise_)) { this.loadFeaturesPromise_ = new Promise((resolve) => { this.loader_.getLoaderFn((features) => { resolve(features); @@ -286,6 +335,7 @@ class KML extends Vector { equals = (this.url === obj.url); equals = equals && (this.name === obj.name); equals = equals && (this.extract === obj.extract); + equals = equals && (this.template === obj.template); } return equals; } diff --git a/mapea-js/src/impl/ol/layer/MVT.js b/mapea-js/src/impl/ol/layer/MVT.js index 85cf453fd..f9b5abf7d 100644 --- a/mapea-js/src/impl/ol/layer/MVT.js +++ b/mapea-js/src/impl/ol/layer/MVT.js @@ -66,6 +66,14 @@ class MVT extends Vector { */ this.mode_ = parameters.mode; + /** + * Function to override the ol tile loading. + * + * @private + * @type {string} + */ + this.tileLoadFunction = vendorOptions?.tileLoadFunction; + /** * Loaded flag attribute * @@ -84,7 +92,6 @@ class MVT extends Vector { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); this.formater_ = new MVTFormatter({ featureClass: this.mode_ === mode.FEATURE ? Feature : RenderFeature, @@ -98,6 +105,7 @@ class MVT extends Vector { format: this.formater_, url, projection: this.projection_, + tileLoadFunction: this.tileLoadFunction, }); // register events in order to fire the LOAD event @@ -127,6 +135,20 @@ class MVT extends Vector { } } }); + this.fire(EventType.ADDED_TO_MAP); + this.facadeVector_?.fire(EventType.ADDED_TO_MAP); + } + + /** + * This function sets + * the tileLoadFunction + * + * @public + * @function + * @api stable + */ + setTileLoadFunction(func){ + this.getOLLayer().getSource().setTileLoadFunction(func); } /** diff --git a/mapea-js/src/impl/ol/layer/Mapbox.js b/mapea-js/src/impl/ol/layer/Mapbox.js index 4e40a796d..2fc304c9a 100644 --- a/mapea-js/src/impl/ol/layer/Mapbox.js +++ b/mapea-js/src/impl/ol/layer/Mapbox.js @@ -59,6 +59,9 @@ class Mapbox extends Layer { this.visibility = false; } + // sets tileLoadFunction + this.tileLoadFunction = vendorOptions?.tileLoadFunction; + this.zIndex_ = ImplMap.Z_INDEX[LayerType.Mapbox]; } @@ -107,12 +110,12 @@ class Mapbox extends Layer { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); const extent = this.facadeLayer_.getMaxExtent(); this.ol3Layer = new OLLayerTile(extend({ source: new OLSourceXYZ({ url: `${this.url}${this.name}/{z}/{x}/{y}.png?${M.config.MAPBOX_TOKEN_NAME}=${this.accessToken}`, + tileLoadFunction: this.tileLoadFunction, }), extent, }, this.vendorOptions_, true)); @@ -155,8 +158,100 @@ class Mapbox extends Layer { // activates animation for base layers or animated parameters const animated = ((this.transparent === false) || (this.options.animated === true)); this.ol3Layer.set('animated', animated); + this.fire(EventType.ADDED_TO_MAP); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP); } + /** + * Removes and creates the ol3layer + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + const olMap = this.map.getMapImpl(); + if (!isNullOrEmpty(this.ol3Layer)) { + olMap.removeLayer(this.ol3Layer); + this.ol3Layer = null; + } + + this.map.getLayers().forEach((layer) => { + if (layer instanceof FacadeMapbox || layer instanceof FacadeOSM) { + this.haveOSMorMapboxLayer = true; + } + }); + + if (!this.haveOSMorMapboxLayer) { + this.map.getImpl().getMapImpl().getControls().getArray() + .forEach((data) => { + if (data instanceof OLControlAttribution) { + this.map.getImpl().getMapImpl().removeControl(data); + } + }); + } + + + const extent = this.facadeLayer_.getMaxExtent(); + this.ol3Layer = new OLLayerTile(extend({ + source: new OLSourceXYZ({ + url: `${this.url}${this.name}/{z}/{x}/{y}.png?${M.config.MAPBOX_TOKEN_NAME}=${this.accessToken}`, + tileLoadFunction: this.tileLoadFunction, + }), + extent, + }, this.vendorOptions_, true)); + + this.map.getMapImpl().addLayer(this.ol3Layer); + + // recalculate resolutions + this.map.getMapImpl().updateSize(); + const size = this.map.getMapImpl().getSize(); + const units = this.map.getProjection().units; + this.resolutions_ = generateResolutionsFromExtent(this.getExtent(), size, 16, units); + + // sets its visibility if it is in range + if (this.isVisible() && !this.inRange()) { + this.setVisible(false); + } + if (this.zIndex_ !== null) { + this.setZIndex(this.zIndex_); + } + + // sets the resolutions + if (this.resolutions_ !== null) { + this.setResolutions(this.resolutions_); + } + + // activates animation for base layers or animated parameters + const animated = ((this.transparent === false) || (this.options.animated === true)); + this.ol3Layer.set('animated', animated); + } + + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + + /** + * Sets the name of the layer + * + * @public + * @function + * @api stable + */ + setName(newName) { + this.name = newName; + this.recreateOlLayer(); + } + /** * This function sets the resolutions for this layer * @@ -176,11 +271,24 @@ class Mapbox extends Layer { extent, resolutions, attributionControl: true, + tileLoadFunction: this.tileLoadFunction, }); this.ol3Layer.setSource(newSource); } } + /** + * This function sets + * the tileLoadFunction + * + * @public + * @function + * @api stable + */ + setTileLoadFunction(func){ + this.getOLLayer().getSource().setTileLoadFunction(func); + } + /** * This function gets the envolved extent for * this WMS diff --git a/mapea-js/src/impl/ol/layer/OSM.js b/mapea-js/src/impl/ol/layer/OSM.js index 8f5a1d280..179926b23 100644 --- a/mapea-js/src/impl/ol/layer/OSM.js +++ b/mapea-js/src/impl/ol/layer/OSM.js @@ -59,6 +59,9 @@ class OSM extends Layer { this.visibility = false; } + // sets tileLoadFunction + this.tileLoadFunction = vendorOptions?.tileLoadFunction; + this.zIndex_ = ImplMap.Z_INDEX[LayerType.OSM]; // URL @@ -110,7 +113,6 @@ class OSM extends Layer { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); this.ol3Layer = new OLLayerTile(extend({}, this.vendorOptions_, true)); this.updateSource_(); @@ -154,6 +156,8 @@ class OSM extends Layer { // set the extent when the map changed this.map.on(EventType.CHANGE_PROJ, () => this.updateSource_()); + this.fire(EventType.ADDED_TO_MAP); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP); } /** @@ -191,15 +195,30 @@ class OSM extends Layer { if (!isUndefined(this.url_)) { newSource = new SourceXYZ({ url: this.url_, + tileLoadFunction: this.tileLoadFunction, }); } else { - newSource = new SourceOSM({}); + newSource = new SourceOSM({ + tileLoadFunction: this.tileLoadFunction, + }); } this.ol3Layer.setSource(newSource); this.ol3Layer.setExtent(extent); } } + /** + * This function sets + * the tileLoadFunction + * + * @public + * @function + * @api stable + */ + setTileLoadFunction(func){ + this.getOLLayer().getSource().setTileLoadFunction(func); + } + /** * This function set facade class OSM * diff --git a/mapea-js/src/impl/ol/layer/Vector.js b/mapea-js/src/impl/ol/layer/Vector.js index b9767905c..9a2ca80ab 100644 --- a/mapea-js/src/impl/ol/layer/Vector.js +++ b/mapea-js/src/impl/ol/layer/Vector.js @@ -87,7 +87,6 @@ class Vector extends Layer { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); map.on(EventType.CHANGE_PROJ, this.setProjection_.bind(this), this); this.ol3Layer = new OLLayerVector(this.vendorOptions_); @@ -99,6 +98,8 @@ class Vector extends Layer { this.setVisible(this.visibility); const olMap = this.map.getMapImpl(); olMap.addLayer(this.ol3Layer); + this.fire(EventType.ADDED_TO_MAP); + this.facadeVector_?.fire(EventType.ADDED_TO_MAP); } /** @@ -305,10 +306,17 @@ class Vector extends Layer { if (isFunction(clickFn)) { clickFn(evt, feature); } else { - const htmlAsText = compileTemplate(PopupTemplate, { + const popup_template = !isNullOrEmpty(this.template) ? this.template : PopupTemplate; + + let htmlAsText = compileTemplate(popup_template, { vars: this.parseFeaturesForTemplate_(features), parseToHtml: false, }); + if (this.name){ + const layerNameHTML = `
${this.name}
` + htmlAsText = layerNameHTML + htmlAsText; + } + const featureTabOpts = { icon: 'g-cartografia-pin', title: this.name, @@ -485,7 +493,12 @@ class Vector extends Layer { resolve(extent); } else { this.requestFeatures_().then((features) => { - const extent = ImplUtils.getFeaturesExtent(features, codeProj); + const features_arr = features.features + && !Array.isArray(features) + && Array.isArray(features.features) + ? features.features + : features; + const extent = ImplUtils.getFeaturesExtent(features_arr, codeProj); resolve(extent); }); } diff --git a/mapea-js/src/impl/ol/layer/WFS.js b/mapea-js/src/impl/ol/layer/WFS.js index c4c9d39a6..a1b1cd15f 100644 --- a/mapea-js/src/impl/ol/layer/WFS.js +++ b/mapea-js/src/impl/ol/layer/WFS.js @@ -103,6 +103,18 @@ class WFS extends Vector { this.updateSource_(forceNewSource); } + /** + * Removes and creates the ol3layer + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + this.refresh(true); + } + /** * This function sets the map object of the layer * @@ -245,6 +257,54 @@ class WFS extends Vector { return defaultValue; } + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + + /** + * Sets the name of the layer + * + * @public + * @function + * @api stable + */ + setName(newName) { + this.name = newName; + this.recreateOlLayer(); + } + + /** + * Sets the namespace of the layer + * + * @public + * @function + * @api stable + */ + setNamespace(newNamespace) { + this.namespace = newNamespace; + this.recreateOlLayer(); + } + + /** + * Sets the geometry of the layer + * + * @public + * @function + * @api stable + */ + setGeometry(newGeometry) { + this.geometry = newGeometry; + this.recreateOlLayer(); + } + // /** // * This function destroys this layer, cleaning the HTML // * and unregistering all events diff --git a/mapea-js/src/impl/ol/layer/WMC.js b/mapea-js/src/impl/ol/layer/WMC.js index 597916279..677b43946 100644 --- a/mapea-js/src/impl/ol/layer/WMC.js +++ b/mapea-js/src/impl/ol/layer/WMC.js @@ -83,6 +83,7 @@ class WMC extends Layer { addTo(map) { this.map = map; this.fire(EventType.ADDED_TO_MAP); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP); } /** diff --git a/mapea-js/src/impl/ol/layer/WMS.js b/mapea-js/src/impl/ol/layer/WMS.js index 3a814361e..2a2020e27 100644 --- a/mapea-js/src/impl/ol/layer/WMS.js +++ b/mapea-js/src/impl/ol/layer/WMS.js @@ -89,6 +89,13 @@ class WMS extends LayerBase { */ this.getCapabilitiesPromise = null; + /** + * Function to override the tile loading + * @private + * @type {Function} + */ + this.tileLoadFunction = vendorOptions?.tileLoadFunction; + /** * get WMS extent promise * @private @@ -200,7 +207,6 @@ class WMS extends LayerBase { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); // calculates the resolutions from scales if (!isNull(this.options) && @@ -227,6 +233,8 @@ class WMS extends LayerBase { SLD_VERSION: '1.1.0', }); } + this.fire(EventType.ADDED_TO_MAP); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP); } /** @@ -340,6 +348,7 @@ class WMS extends LayerBase { TRANSPARENT: this.transparent, FORMAT: 'image/png', STYLES: this.styles, + CQL_FILTER: this.cql, }; if (!isNullOrEmpty(this.sldBody)) { @@ -367,11 +376,15 @@ class WMS extends LayerBase { maxResolution, opacity, zIndex, + myparam: "aa", }; if (!isUndefined(crossOrigin)) { opts.crossOrigin = crossOrigin; } - olSource = new TileWMS(opts); + + opts.tileLoadFunction = this.tileLoadFunction; + + olSource = new TileWMS(opts); olSource.updateParams(layerParams); } else { const opts = { @@ -429,6 +442,42 @@ class WMS extends LayerBase { }); } + /** + * This function sets + * the tileLoadFunction + * + * @public + * @function + * @api stable + */ + setTileLoadFunction(func){ + this.getOLLayer().getSource().setTileLoadFunction(func); + } + + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + + /** + * Sets the name of the layer + * + * @public + * @function + * @api stable + */ + setName(newName) { + this.name = newName; + this.recreateOlLayer(); + } + /** * This function gets the envolved extent for * this WMS @@ -656,6 +705,22 @@ class WMS extends LayerBase { } } + /** + * Removes and creates the ol3layer + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + const olMap = this.map.getMapImpl(); + if (!isNullOrEmpty(this.ol3Layer)) { + olMap.removeLayer(this.ol3Layer); + } + this.addSingleLayer_(); + } + /** * TODO * diff --git a/mapea-js/src/impl/ol/layer/WMTS.js b/mapea-js/src/impl/ol/layer/WMTS.js index 576ff47d7..c0312f9bf 100644 --- a/mapea-js/src/impl/ol/layer/WMTS.js +++ b/mapea-js/src/impl/ol/layer/WMTS.js @@ -72,6 +72,13 @@ class WMTS extends LayerBase { style: 'default', format: 'image/jpeg', }; + + /** + * Function to override the tile loading + * @private + * @type {Function} + */ + this.tileLoadFunction = vendorOptions?.tileLoadFunction; } /** @@ -84,7 +91,6 @@ class WMTS extends LayerBase { */ addTo(map) { this.map = map; - this.fire(EventType.ADDED_TO_MAP); // calculates the resolutions from scales if (!isNull(this.options) && @@ -101,6 +107,8 @@ class WMTS extends LayerBase { } else { this.addLayer_(capabilitiesOpts); } + this.fire(EventType.ADDED_TO_MAP); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP); } /** @@ -142,6 +150,8 @@ class WMTS extends LayerBase { opts.crossOrigin = crossOrigin; } + opts.tileLoadFunction = this.tileLoadFunction; + const newSource = new OLSourceWMTS(opts); this.ol3Layer.setSource(newSource); }); @@ -204,6 +214,7 @@ class WMTS extends LayerBase { // matrixIds, // }), extent, + tileLoadFunction: this.tileLoadFunction, }, true)); this.ol3Layer = new OLLayerTile(extend({ @@ -229,6 +240,7 @@ class WMTS extends LayerBase { this.ol3Layer.set('animated', true); this.fire(EventType.ADDED_TO_MAP, this); + this.facadeLayer_?.fire(EventType.ADDED_TO_MAP, this); } /** @@ -274,6 +286,42 @@ class WMTS extends LayerBase { return this.capabilitiesOptionsPromise; } + /** + * This function sets + * the tileLoadFunction + * + * @public + * @function + * @api stable + */ + setTileLoadFunction(func){ + this.getOLLayer().getSource().setTileLoadFunction(func); + } + + /** + * Sets the url of the layer + * + * @public + * @function + * @api stable + */ + setURL(newURL) { + this.url = newURL; + this.recreateOlLayer(); + } + + /** + * Sets the name of the layer + * + * @public + * @function + * @api stable + */ + setName(newName) { + this.name = newName; + this.recreateOlLayer(); + } + /** * TODO * @@ -331,6 +379,28 @@ class WMTS extends LayerBase { this.facadeLayer_ = obj; } + /** + * Removes and creates the ol3layer + * + * @public + * @function + * @api stable + * @export + */ + recreateOlLayer() { + const olMap = this.map.getMapImpl(); + if (!isNullOrEmpty(this.ol3Layer)) { + olMap.removeLayer(this.ol3Layer); + } + + const capabilitiesOpts = this.getCapabilitiesOptions_(); + if (capabilitiesOpts instanceof Promise) { + capabilitiesOpts.then(capabilitiesOptions => this.addLayer_(capabilitiesOptions)); + } else { + this.addLayer_(capabilitiesOpts); + } + } + /** * This function destroys this layer, cleaning the HTML * and unregistering all events diff --git a/mapea-js/src/plugins/geosearch/facade/js/geosearchcontrol.js b/mapea-js/src/plugins/geosearch/facade/js/geosearchcontrol.js index 87cebbb66..4a4a36fa6 100644 --- a/mapea-js/src/plugins/geosearch/facade/js/geosearchcontrol.js +++ b/mapea-js/src/plugins/geosearch/facade/js/geosearchcontrol.js @@ -183,7 +183,6 @@ export default class GeosearchControl extends M.Control { * @api stabletrue */ createImagesCache(html) { - console.log(html); const container = html.getElementsByClassName("img-cache-loader")[0]; const urls = [ diff --git a/mapea-js/src/plugins/geosearchbycoordinates/facade/js/geosearchbycoordinatescontrol.js b/mapea-js/src/plugins/geosearchbycoordinates/facade/js/geosearchbycoordinatescontrol.js index 993b7ccfc..f8aa2747a 100644 --- a/mapea-js/src/plugins/geosearchbycoordinates/facade/js/geosearchbycoordinatescontrol.js +++ b/mapea-js/src/plugins/geosearchbycoordinates/facade/js/geosearchbycoordinatescontrol.js @@ -157,7 +157,6 @@ export default class GeosearchByCoordinatesControl extends GeosearchControl { * @api stabletrue */ createImagesCache(html) { - console.log(html); const container = html.getElementsByClassName("img-cache-loader")[0]; const urls = [ diff --git a/mapea-js/src/plugins/geosearchbylocation/facade/js/geosearchbylocationcontrol.js b/mapea-js/src/plugins/geosearchbylocation/facade/js/geosearchbylocationcontrol.js index ba43c4148..2fe4dc6b5 100644 --- a/mapea-js/src/plugins/geosearchbylocation/facade/js/geosearchbylocationcontrol.js +++ b/mapea-js/src/plugins/geosearchbylocation/facade/js/geosearchbylocationcontrol.js @@ -139,7 +139,6 @@ export default class GeosearchbylocationControl extends GeosearchControl { * @api stabletrue */ createImagesCache(html) { - console.log(html); const container = html.getElementsByClassName("img-cache-loader")[0]; const urls = [ diff --git a/mapea-js/src/plugins/searchstreetgeosearch/facade/assets/css/searchstreetgeosearch.css b/mapea-js/src/plugins/searchstreetgeosearch/facade/assets/css/searchstreetgeosearch.css index 88e25ed3f..7f68a8913 100644 --- a/mapea-js/src/plugins/searchstreetgeosearch/facade/assets/css/searchstreetgeosearch.css +++ b/mapea-js/src/plugins/searchstreetgeosearch/facade/assets/css/searchstreetgeosearch.css @@ -68,6 +68,10 @@ } } +.m-hidden { + display: none; +} + /**************************** INTERNET EXPLORER HACKS ****************************/ diff --git a/mapea-js/src/plugins/searchstreetgeosearch/facade/js/searchstreetgeosearchcontrol.js b/mapea-js/src/plugins/searchstreetgeosearch/facade/js/searchstreetgeosearchcontrol.js index ce10cba19..d56f29954 100644 --- a/mapea-js/src/plugins/searchstreetgeosearch/facade/js/searchstreetgeosearchcontrol.js +++ b/mapea-js/src/plugins/searchstreetgeosearch/facade/js/searchstreetgeosearchcontrol.js @@ -226,11 +226,39 @@ export default class SearchstreetGeosearchControl extends M.Control { geosearchResuts.classList.add('show'); } }); + this.createImagesCache(html); return new Promise((resolve) => { resolve(html); }); } + /** + * This function creates the images cache + * + * @public + * @function + * @param {M.Map} map to add the control + * @api stabletrue + */ + createImagesCache(html) { + const container = html.getElementsByClassName("img-cache-loader")[0]; + + const urls = [ + '/img/m-pin-24.svg', + '/img/m-pin-24-new.svg', + '/img/m-pin-24-sel.svg' + ]; + + urls.forEach(url => { + let img = new Image(); + img.src = M.utils.concatUrlPaths([M.config.THEME_URL, url]); + img.width = '24'; + img.height = '24'; + img.crossOrigin = 'anonymous'; + container.append(img); + }); + } + /** * This query returns the input SearchstreetGeosearch * diff --git a/mapea-js/src/plugins/searchstreetgeosearch/templates/searchstreetgeosearch.html b/mapea-js/src/plugins/searchstreetgeosearch/templates/searchstreetgeosearch.html index eccf27da8..d65b61b2a 100644 --- a/mapea-js/src/plugins/searchstreetgeosearch/templates/searchstreetgeosearch.html +++ b/mapea-js/src/plugins/searchstreetgeosearch/templates/searchstreetgeosearch.html @@ -30,4 +30,7 @@ + +
+
diff --git a/mapea-js/test/development/all-controls-mapbox.js b/mapea-js/test/development/all-controls-mapbox.js index 0848d53a6..beb60bbc0 100644 --- a/mapea-js/test/development/all-controls-mapbox.js +++ b/mapea-js/test/development/all-controls-mapbox.js @@ -1,9 +1,25 @@ import { map } from 'M/mapea'; +import MAPBOX from 'M/layer/Mapbox'; -window.map = map({ + +const mapjs = map({ container: 'map', controls: ['scale', 'scaleline', 'panzoombar', 'panzoom', 'layerswitcher', 'mouse', 'overviewmap', 'location'], getfeatureinfo: 'plain', - layers: ['MAPBOX*mapbox.satellite'], + // layers: ['MAPBOX*mapbox.satellite'], projection: 'EPSG:3857*m', }); +window.map = mapjs; + +const mapboxLayer = new MAPBOX( + 'MAPBOX*mapbox.satellite', + // {}, + // { + // tileLoadFunction: function(imageTile, src) { + // imageTile.getImage().src = src; + // console.log('tile cargada mapbox'); + // } + // } +); + +mapjs.addLayers([mapboxLayer]); \ No newline at end of file diff --git a/mapea-js/test/development/all-layers-mapbox.js b/mapea-js/test/development/all-layers-mapbox.js index 4bf4dba26..c0669498a 100644 --- a/mapea-js/test/development/all-layers-mapbox.js +++ b/mapea-js/test/development/all-layers-mapbox.js @@ -12,9 +12,12 @@ window.mapjs = map({ }); const wms = new WMS({ - url: 'http://www.ideandalucia.es/wms/mta10v_2007?', - name: 'Limites', -}); + url: 'http://www.juntadeandalucia.es/institutodeestadisticaycartografia/geoserver-ieca/grid/wms?', + name: 'gridp_250', + namespace: "grid", +}, {}, { + // cql: `cmun LIKE '%18%'`, +},); const wfs = new WFS({ namespace: 'ggis', diff --git a/mapea-js/test/development/all-layers.js b/mapea-js/test/development/all-layers.js index 8f2be36d0..b1b2d2591 100644 --- a/mapea-js/test/development/all-layers.js +++ b/mapea-js/test/development/all-layers.js @@ -12,7 +12,31 @@ window.mapjs = map({ const wms = new WMS({ url: 'http://www.ideandalucia.es/wms/mta10v_2007?', name: 'Limites', -}); +}, +// {}, +// { +// tileLoadFunction: (tile, src)=>{ + +// const xhr = new XMLHttpRequest(); +// xhr.responseType = 'blob'; +// xhr.addEventListener('loadend', function (evt) { +// const data = this.response; +// if (data !== undefined) { +// tile.getImage().src = URL.createObjectURL(data); +// } else { +// tile.setState(TileState.ERROR); +// } +// }); +// xhr.addEventListener('error', function () { +// tile.setState(TileState.ERROR); +// }); +// xhr.open('GET', src); +// xhr.send(); + +// console.log('tile cargada WMS'); +// }, +// } +); var wfs = new WFS({ url: "http://geostematicos-sigc.juntadeandalucia.es/geoserver/tematicos/ows?", diff --git a/mapea-js/test/development/attribute.html b/mapea-js/test/development/attribute.html index 89a7e63d7..55379b707 100644 --- a/mapea-js/test/development/attribute.html +++ b/mapea-js/test/development/attribute.html @@ -7,7 +7,7 @@ - + PRUEBA PRINTER @@ -32,8 +32,8 @@
- - + + diff --git a/mapea-js/test/development/basic-map-osm.js b/mapea-js/test/development/basic-map-osm.js index 7749fb5b5..31c9d4f8e 100644 --- a/mapea-js/test/development/basic-map-osm.js +++ b/mapea-js/test/development/basic-map-osm.js @@ -1,8 +1,35 @@ import { map } from 'M/mapea'; +import OSM from 'M/layer/OSM'; -window.map = map({ +const mapjs = map({ container: 'map', - layers: ['OSM'], + // layers: ['OSM'], projection: 'EPSG:3857*m', controls: ['overviewmap', 'scale', 'scaleline', 'panzoombar', 'panzoom', 'layerswitcher', 'mouse', 'location'], }); +window.map = mapjs; + +mapjs.addLayers([new OSM('', +// {}, +// { +// tileLoadFunction: ((tile, src)=>{ +// const xhr = new XMLHttpRequest(); +// xhr.responseType = 'blob'; +// xhr.addEventListener('loadend', function (evt) { +// const data = this.response; +// if (data !== undefined) { +// tile.getImage().src = URL.createObjectURL(data); +// } else { +// tile.setState(TileState.ERROR); +// } +// }); +// xhr.addEventListener('error', function () { +// tile.setState(TileState.ERROR); +// }); +// xhr.open('GET', src); +// xhr.send(); + +// console.log('capa cargada OSM'); +// }), +// } +)]); diff --git a/mapea-js/test/development/kml.js b/mapea-js/test/development/kml.js index 63b9a9c78..b59292532 100644 --- a/mapea-js/test/development/kml.js +++ b/mapea-js/test/development/kml.js @@ -1,5 +1,6 @@ import { map } from 'M/mapea'; import KML from 'M/layer/KML'; +import template from '../development/templates/customKMLPopupTemplate.html' const mapjs = map({ container: 'map', @@ -9,6 +10,7 @@ const LayerKml = new KML({ url: 'http://mapea-sigc.juntadeandalucia.es/sepim_server/api/datos/kml/1193/item/341', name: 'capaKML', extract: true, + template: template, }); mapjs.addKML(LayerKml); diff --git a/mapea-js/test/development/layer-vectortile.js b/mapea-js/test/development/layer-vectortile.js index 93945b601..573bd049b 100644 --- a/mapea-js/test/development/layer-vectortile.js +++ b/mapea-js/test/development/layer-vectortile.js @@ -13,6 +13,17 @@ const mvt = new MVT({ url: 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/CHG:carmenmarquez_municipios_20200916_16431@EPSG:900913@pbf/{z}/{x}/{-y}.pbf', name: 'vectortile', projection: 'EPSG:3857', +}, +// {}, +// { +// tileLoadFunction: function() { +// console.log('loading tile mvt'); +// }, +// } +); + +mvt.on('added:map', () => { + console.log('mvt añadido'); }); mapjs.addLayers(mvt); window.mapjs = mapjs; diff --git a/mapea-js/test/development/layer-wmts.js b/mapea-js/test/development/layer-wmts.js index 0d8a5c496..2c55b8d31 100644 --- a/mapea-js/test/development/layer-wmts.js +++ b/mapea-js/test/development/layer-wmts.js @@ -122,7 +122,7 @@ const layer2 = new WMTS({ url: "http://www.ideandalucia.es/geowebcache/service/wmts", name: "orto_2010-11", matrixSet: "EPSG:25830", - legend: "orto_2010-11" + legend: "orto_2010-11", }, { capabilities: { "urls": [ @@ -137,6 +137,31 @@ const layer2 = new WMTS({ "style": "", "dimensions": {} }, -}); +}, +// { +// tileLoadFunction: ((tile, src)=>{ +// const xhr = new XMLHttpRequest(); +// xhr.responseType = 'blob'; +// xhr.addEventListener('loadend', function (evt) { +// const data = this.response; +// if (data !== undefined) { +// tile.getImage().src = URL.createObjectURL(data); +// } else { +// tile.setState(TileState.ERROR); +// } +// }); +// xhr.addEventListener('error', function () { +// tile.setState(TileState.ERROR); +// }); +// xhr.open('GET', src); +// xhr.send(); + +// console.log('tile cargada WMTS'); +// }), +// } +); +layer2.on('added:map', () => { + console.log('layer2 añadido'); +}); mapajs.addWMTS(layer2); diff --git a/mapea-js/test/development/plugins.html b/mapea-js/test/development/plugins.html index e4932260b..b7d49f35b 100644 --- a/mapea-js/test/development/plugins.html +++ b/mapea-js/test/development/plugins.html @@ -8,7 +8,7 @@ PRUEBA DESARROLLO - +