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

Fire 'loadstart' event for layer- element based on MapML parsing. #73

Merged
merged 1 commit into from
Nov 28, 2017
Merged
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
18 changes: 17 additions & 1 deletion map-layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
hreflang: null,
sizes: null }];
}
if (this._layer._title && this.label === "Layer") {
this.label = this._layer._title;
}
// make sure local content layer has the chance to set its extent properly
// which is important for the layer control and the disabled property
if (this._layer._map) {
Expand Down Expand Up @@ -157,6 +160,7 @@
if (this._layerControl && !this.hidden) {
this._layerControl.removeLayer(this._layer);
}
this._removeEvents();
},
ready: function() {

Expand All @@ -169,6 +173,7 @@
var base = this.baseURI ? this.baseURI : document.baseURI;
this._layer = M.mapMLLayer(this.src ? new URI(this.src).resolve(new URI(base)).toString(): null, this);
this._layer.on('extentload', this._onLayerExtentLoad, this);
this._setUpEvents();
},
_attachedToMap: function() {
// set i to the index of this layer element in the set of layers
Expand Down Expand Up @@ -209,13 +214,24 @@
},
attached: function() {
if (Polymer.dom(this).parentNode.nodeName !== 'MAP') {
console.log('Info: '+ this.localName + '#' + this.id + ' must be a child of a map element');
console.log('ERROR: '+ this.localName + '#' + this.id + ' must be a child of a map element');
return;
}
// if the map has been attached, set this layer up wrt Leaflet map
if (Polymer.dom(this).parentNode._map) {
this._attachedToMap();
}
},
_removeEvents: function() {
if (this._layer) {
this._layer.off('loadstart', false, this);
}
},
_setUpEvents: function () {
this._layer.on('loadstart',
function () {
this.fire('loadstart', {target: this});
}, this);
}
});
</script>
Expand Down
3 changes: 2 additions & 1 deletion web-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/* try to constrain the map and the leaflet div#map to the size of the container */
:host, :host #map {
max-width: 100%;
min-width: 100%;
}
/* this is a hack for shady DOM, as max-width messes with Leaflet tiles */
:host img {
Expand Down Expand Up @@ -230,7 +231,7 @@
// there is a better configuration than that, but at this moment
// I'm not sure how to approach that issue.
// See https://github.com/Maps4HTML/MapML-Leaflet-Client/issues/24
fadeAnimation: false
fadeAnimation: true
});

// optionally add controls to the map
Expand Down