Skip to content

Commit

Permalink
Merge pull request #72 from leslieli/master
Browse files Browse the repository at this point in the history
MAX-26939: Apply the new design for the menus on polygon tool
  • Loading branch information
leslieli authored Jun 14, 2022
2 parents 506195a + 7f403e0 commit 984417f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v3.19.26
===================
## Enhancement:
* Add new function `_toggleShapeBtnsEnableState` to enable/disable the shape creation buttons.
* Enhance the logic of `_handleShapeLayerDrawEnd`.

v3.19.25
===================
## Enhancement:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "px-map",
"version": "3.19.25",
"version": "3.19.26",
"description": "A lightweight framework for building interactive maps with web components",
"main": [
"px-map.html"
Expand Down
5 changes: 5 additions & 0 deletions demo/px-map-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,17 @@

mapMove: function(evt) {
var markers = Polymer.dom(evt).rootTarget.getVisibleMarkers();
if (Polymer.dom(evt).rootTarget.elementInst.pm) {
Polymer.dom(evt).rootTarget.elementInst.pm.disableDraw();
}
console.log('There are ' + markers.length + ' markers visible on the map.');
},
drawFinished: function(evt) {
Polymer.dom(evt).rootTarget._removeDrawnLayers();
console.log('There is the feature collection for the drawn polygon.', evt.detail);
},
drawnLayerChanged: function(evt) {
Polymer.dom(evt).rootTarget._toggleShapeBtnsEnableState(!evt.detail.hasDrawnLayers);
console.log('The drawn layer is changed, still has layer on map?', evt.detail);
},
removalModeChanged: function(evt) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "px-map",
"author": "General Electric",
"description": "A lightweight framework for building interactive maps with web components",
"version": "3.19.25",
"version": "3.19.26",
"private": false,
"extName": null,
"repository": {
Expand Down
19 changes: 17 additions & 2 deletions px-map-behavior-root.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,17 @@
}
},

/**
* Enable/Disable the shape buttons
*
* @param {*} enable
*/
_toggleShapeBtnsEnableState(enable) {
this.elementInst.pm.Toolbar.setButtonDisabled('Rectangle', !enable);
this.elementInst.pm.Toolbar.setButtonDisabled('Polygon', !enable);
this.elementInst.pm.Toolbar.setButtonDisabled('Circle', !enable);
},

/**
* Update the drawing toolbar position
* @param {*} position
Expand Down Expand Up @@ -566,11 +577,15 @@

/**
* Handle when the layer or shape is draw ended.
*
* @param {*} e
*/
_handleShapeLayerDrawEnd(e) {
this._toggleFinishBtnEnalbeState(true);
this.fire('px-map-drawn-layer-changed', { hasDrawnLayers: true });
// drawend event is triggerred as well when disable the draw for the first shape/layer
// can't use hasLayers = true directly here
const hasLayers = this._hasDrawnLayers();
this._toggleFinishBtnEnalbeState(hasLayers);
this.fire('px-map-drawn-layer-changed', { hasDrawnLayers: hasLayers });
},

/**
Expand Down

0 comments on commit 984417f

Please sign in to comment.