@trimblemaps/trimblemaps-mapmenus
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@trimblemaps/trimblemaps-mapmenus", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Map control for switching map styles in the JavaScript Maps SDK.", | ||
@@ -5,0 +5,0 @@ "main": "trimblemaps-mapmenus.js", |
@@ -52,2 +52,3 @@ import TrimbleMaps from '@trimblemaps/trimblemaps-js'; | ||
private _mapBasedContentLayers; | ||
private _urls; | ||
constructor(options: MapMenusOptions); | ||
@@ -69,2 +70,8 @@ onAdd(map: TrimbleMaps.Map): HTMLElement; | ||
/** | ||
* @private | ||
* | ||
* @param {Object} newUrls Object properties should match the urls build config. | ||
*/ | ||
_setServiceUrls(newUrls: object): void; | ||
/** | ||
* Set the visibility of the content layer. | ||
@@ -71,0 +78,0 @@ * @param layerName Name of the content layer. |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@trimblemaps/trimblemaps-js")):"function"==typeof define&&define.amd?define(["@trimblemaps/trimblemaps-js"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).TrimbleMapsControl=e.TrimbleMapsControl||{},e.TrimbleMapsControl.MapMenus=t(e.TrimbleMaps))}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=t(e),s=[{id:"traffic",name:"Traffic Congestion",isVisible:!1,isLoaded:!1,layerName:"Traffic",icon:"traffic",minZoom:9,isLicensed:!0},{id:"trafficincident",name:"Traffic Incidents",isVisible:!1,isLoaded:!1,layerName:"TrafficIncident",icon:"incidents",minZoom:12,isLicensed:!0},{id:"trafficcamera",name:"Traffic Cameras",isVisible:!1,isLoaded:!1,layerName:"TrafficCamera",icon:"camera",minZoom:12,isLicensed:!0},{id:"weatherradar",name:"Weather Radar",isVisible:!1,isLoaded:!1,layerName:"WeatherRadar",icon:"radar",minZoom:0,isLicensed:!0},{id:"weathercloud",name:"Weather Clouds",isVisible:!1,isLoaded:!1,layerName:"WeatherCloud",icon:"cloud",minZoom:0,isLicensed:!0},{id:"weatheralert",name:"Weather Alerts",isVisible:!1,isLoaded:!1,layerName:"WeatherAlert",icon:"alerts",minZoom:0,isLicensed:!0},{id:"roadsurface",name:"Weather Road Surface",isVisible:!1,isLoaded:!1,layerName:"RoadSurface",icon:"surfaces",minZoom:1,isLicensed:!0},{id:"truckrestriction",name:"Truck Restrictions",isVisible:!1,isLoaded:!1,layerName:"TruckRestriction",icon:"restrictions",minZoom:14,isLicensed:!0},{id:"customroad",name:"Custom Roads",isVisible:!1,isLoaded:!1,layerName:"CustomRoad",icon:"customroad",minZoom:4,isLicensed:!1},{id:"building3d",name:"3D Buildings",isVisible:!1,isLoaded:!1,layerName:"3dBuilding",icon:"3d_buildings",minZoom:14,isLicensed:!0},{id:"pointsofinterest",name:"Points of Interest",isVisible:!1,isLoaded:!1,layerName:"PointsOfInterest",icon:"poi",minZoom:12,isLicensed:!0},{id:"places",name:"Places",isVisible:!1,isLoaded:!1,layerName:"Places",icon:"places",minZoom:12,isLicensed:!0}],a=function(){function e(){this.mapHandlers=new Map}return e.prototype.setMap=function(e){this.map=e},e.prototype.add=function(e){if(this.map){this.map.on(e.eventName,e.listener);var t=e.eventName+Date.now();return this.mapHandlers.set(t,e),t}console.warn("Handler cannot be added. The map has not been set for this manager.")},e.prototype.remove=function(e){var t=this.mapHandlers.get(e);this.map.off(t.eventName,t.listener),this.mapHandlers.delete(e)},e.prototype.removeAll=function(){var e=this;this.mapHandlers.forEach((function(t){e.map.off(t.eventName,t.listener)})),this.mapHandlers.clear()},e}(),n="https://tiles.alk.com/styles/";var o={showContentLayers:!0,showBaseStyles:!0,showCustomStyles:!1,showMobileStyles:!1,hideLayers:[],hideStyles:[]},l=function(){function e(e){var t=this;this._mapHandlerManager=new a,this._mapBasedContentLayers=["building3d","places"],this._options=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var s=0,a=t;s<a.length;s++){var n=a[s];for(var o in n)e[o]=n[o]}return e}({},o,e),this._hasStyles=this._options.showBaseStyles||this._options.showCustomStyles||this._options.showMobileStyles,this._hasLayers=this._options.showContentLayers,this._outsideClickListener=function(e){var i,s;t._container.contains(e.target)||(null===(i=t._styleMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open"),null===(s=t._layerMenu)||void 0===s||s.classList.remove("trimblemaps-menu-container-open"))}}return e.prototype.onAdd=function(e){var t=this;this._map=e,this._mapHandlerManager.setMap(this._map),this._container=document.createElement("div"),this._container.className="trimblemaps-ctrl trimblemaps-ctrl-group trimblemaps-menu-ctrl";var i=document.createElement("button");i.className="trimblemaps-ctrl-icon trimblemaps-menu-styles-button",i.title="Map styles",i.type="button",i.addEventListener("click",(function(){t._toggleStyleMenu()}));var s=document.createElement("button");s.className="trimblemaps-ctrl-icon trimblemaps-menu-layers-button",s.title="Content layers",s.type="button",s.addEventListener("click",(function(){t._toggleLayerMenu()}));var a=document.createElement("div");a.className="trimblemaps-menu-container";var n=document.createElement("div");n.className="trimblemaps-menu-arrow",a.appendChild(n);var o=document.createElement("h5");o.className="trimblemaps-menu-title";var l=document.createElement("div");if(l.className="trimblemaps-menu-list",this._hasStyles&&(this._styleMenu=a.cloneNode(!0),this._styleList=l.cloneNode(!0),o.innerHTML="Map styles",this._styleMenu.appendChild(o.cloneNode(!0)),this._styleMenu.appendChild(this._styleList),this._styleMenu.classList.add("trimblemaps-menu-map-styles"),this._container.appendChild(i),this._container.appendChild(this._styleMenu),this._getStyles()),this._hasLayers){this._layerMenu=a.cloneNode(!0),this._layerList=l.cloneNode(!0),o.innerHTML="Content layers",this._layerMenu.appendChild(o.cloneNode(!0)),this._layerMenu.appendChild(this._layerList),this._layerMenu.classList.add("trimblemaps-menu-content-layers"),this._hasStyles?this._container.insertBefore(s,this._container.childNodes[1]):this._container.appendChild(s),this._container.appendChild(this._layerMenu);var r=document.createElement("div");r.className="trimblemaps-menu-divider",this._layerList.appendChild(r),this._map.once("load",(function(){t._setLayerZoomState()})),this._map.on("zoomend",(function(){t._setLayerZoomState()}))}return this._initializeLayers(),document.addEventListener("click",this._outsideClickListener),this._container},e.prototype.onRemove=function(){var e=this;this._map&&(document.removeEventListener("click",this._outsideClickListener),this._container.parentNode.removeChild(this._container),this._mapHandlerManager.removeAll(),this._contentLayers.forEach((function(t){t.isLoaded&&(e._mapBasedContentLayers.includes(t.id)?e._map["set".concat(t.layerName,"Visibility")](!1):t.layerInstance.remove())})),this._contentLayers=[],this._map=void 0)},e.prototype._getStyles=function(){var e=this,t="".concat(n,"getstylemetadatalist?version=v4&key=").concat(i.default.APIKey);fetch(t).then((function(e){return e.json()})).then((function(t){var i=t,s=document.createElement("div");s.className="trimblemaps-menu-divider";var a=i.filter((function(t){return"base"===t.styleType&&!t.displayName.startsWith("Mobile")&&!t.displayName.startsWith("Simple")&&!e._options.hideStyles.includes(t.displayName)})).sort((function(e,t){return e.displayName>t.displayName?-1:1})),n=i.filter((function(t){return"base"===t.styleType&&t.displayName.startsWith("Mobile")&&!e._options.hideStyles.includes(t.displayName)})),o=i.filter((function(t){return"custom"===t.styleType&&!e._options.hideStyles.includes(t.displayName)})).sort((function(e,t){return e.displayName>t.displayName?1:-1}));e._options.showBaseStyles&&(e._styleList.appendChild(s.cloneNode(!0)),a.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showMobileStyles&&(e._styleList.appendChild(s.cloneNode(!0)),n.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showCustomStyles&&(e._styleList.appendChild(s.cloneNode(!0)),o.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._map.once("styledata",(function(){var t=e._map.style.stylesheet.id.replace("alk_","");e._setSelectedStyle(t)}))}))},e.prototype._initializeLayers=function(){var e=this;this._contentLayers=s.map((function(t){var i=Object.assign({},t);if(e._hasLayers&&!e._options.hideLayers.includes(t.name)&&t.isLicensed){var s=document.createElement("div");s.className="trimblemaps-menu-item trimblemaps-menu-layer-item",s.setAttribute("data-layer-id",i.id),s.setAttribute("data-layer-name",i.name),s.setAttribute("data-layer-minzoom",i.minZoom.toString()),s.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(i.icon,'"></span>\n ').concat(i.name,"\n "),s.addEventListener("click",(function(){e.setContentLayerVisibility(i.name)})),e._layerList.appendChild(s),i.element=s}return i}))},e.prototype._toggleStyleMenu=function(){var e,t;null===(e=this._styleMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._layerMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleLayerMenu=function(){var e,t;null===(e=this._layerMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._styleMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open")},e.prototype._setStyle=function(e){var t=this._getId(e);t!==this._styleList.querySelector(".trimblemaps-item-selected").getAttribute("data-style-id")&&("base"===e.styleType?this._map.setStyle(t):"custom"===e.styleType&&this._map.setStyle("trimblemaps://styles/".concat(t)),this._setSelectedStyle(t)),this._toggleStyleMenu()},e.prototype._setSelectedStyle=function(e){this._styleList.querySelectorAll(".trimblemaps-menu-style-item").forEach((function(t){t.getAttribute("data-style-id")===e?t.classList.add("trimblemaps-item-selected"):t.classList.remove("trimblemaps-item-selected")}))},e.prototype._setLayer=function(e){var t=this;this._setSelectedLayer(e.id),setTimeout((function(){var e;null===(e=t._layerMenu)||void 0===e||e.classList.remove("trimblemaps-menu-container-open")}),350)},e.prototype._setSelectedLayer=function(e){var t;null===(t=this._layerList)||void 0===t||t.querySelectorAll(".trimblemaps-menu-layer-item").forEach((function(t){t.getAttribute("data-layer-id")===e&&t.classList.toggle("trimblemaps-item-selected")}))},e.prototype._setLayerZoomState=function(){var e=this;document.querySelectorAll(".trimblemaps-menu-layer-item").forEach((function(t){var i=parseInt(t.getAttribute("data-layer-minzoom"));e._map.getZoom()>=i?(t.classList.remove("trimblemaps-menu-item-disabled"),t.removeAttribute("title")):(t.classList.add("trimblemaps-menu-item-disabled"),t.setAttribute("title","Does not display until zoom level ".concat(i)))}))},e.prototype._getId=function(e){return e.styleName.split(".")[0]},e.prototype._getThumbnail=function(e,t,i){var s=document.createElement("span");return s.className="trimblemaps-menu-thumbnail",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" xml:space="preserve">\n <path fill="'.concat(e,'" d="M0 0h32v32H0z"/>\n <path fill="').concat(t,'" d="M6 32c1.04-1.44 2.74-3.33 5.36-4.45 1.62-.69 1.93-.39 3.34-1.1 2.45-1.23 2.59-2.7 5.69-5.86 2.45-2.5 2.68-1.9 3.92-3.58 1.83-2.47 1.44-3.91 2.93-6.4C28.02 9.29 29.4 7.56 32 6v26H6z"/>\n <path fill="none" stroke="').concat(i,'" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M-.07 24.79c.97-.46 2.3-1.15 3.8-2.09 1.96-1.23 3.75-2.61 6.14-4.79 4.23-3.87 4.83-5.25 8.51-8.71 2.18-2.05 3.55-2.47 5.62-4.71A28.05 28.05 0 0 0 27.36 0"/>\n <path fill="none" stroke="').concat(i,'" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M11.23 16.74c-2.18-2.57-3.43-4.88-4.19-6.58-.69-1.55-.95-2.57-1.93-3.78C3.6 4.52 1.55 3.66-.01 3.21"/>\n </svg>'),s},e.prototype._getStyleItem=function(e){var t=this,i=document.createElement("div");return i.className="trimblemaps-menu-item trimblemaps-menu-style-item",i.appendChild(this._getThumbnail(e.thumbnailLandColor,e.thumbnailWaterColor,e.thumbnailRoadColor)),i.appendChild(document.createTextNode(e.displayName)),i.setAttribute("data-style-id",this._getId(e)),i.setAttribute("data-style-name",e.displayName),i.addEventListener("click",(function(){t._setStyle(e)})),i},e.prototype.setContentLayerVisibility=function(e,t){var s=this;if(null!==this._map){var a=this._contentLayers.find((function(t){return t.name===e}));if(a)return this._setLayer(a),a.isVisible=t||!a.isVisible,this._mapBasedContentLayers.includes(a.id)?(a.isLoaded||(a.layerHandlerId=this._mapHandlerManager.add({eventName:"style.load",listener:function(){s._map["set".concat(a.layerName,"Visibility")](a.isVisible)}}),a.isLoaded=!0),this._map.isStyleLoaded()&&this._map["set".concat(a.layerName,"Visibility")](a.isVisible),a.isVisible):(a.isLoaded?a.layerInstance.setVisibility(a.isVisible):(a.layerInstance=new i.default[a.layerName],this._map.isStyleLoaded()?a.layerInstance.addTo(this._map):this._map.once("style.load",(function(){a.layerInstance.addTo(s._map)})),a.layerHandlerId=this._mapHandlerManager.add({eventName:a.id,listener:function(){a.isLoaded=!0,a.layerInstance.setVisibility(a.isVisible)}})),a.isVisible);console.warn("".concat(e," is not a valid content layer name."))}else console.warn("This control must be added to a map before content layer visibility can be set.")},e}();return l})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@trimblemaps/trimblemaps-js")):"function"==typeof define&&define.amd?define(["@trimblemaps/trimblemaps-js"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).TrimbleMapsControl=e.TrimbleMapsControl||{},e.TrimbleMapsControl.MapMenus=t(e.TrimbleMaps))}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=t(e),s=[{id:"traffic",name:"Traffic Congestion",isVisible:!1,isLoaded:!1,layerName:"Traffic",icon:"traffic",minZoom:9,isLicensed:!0},{id:"trafficincident",name:"Traffic Incidents",isVisible:!1,isLoaded:!1,layerName:"TrafficIncident",icon:"incidents",minZoom:12,isLicensed:!0},{id:"trafficcamera",name:"Traffic Cameras",isVisible:!1,isLoaded:!1,layerName:"TrafficCamera",icon:"camera",minZoom:12,isLicensed:!0},{id:"weatherradar",name:"Weather Radar",isVisible:!1,isLoaded:!1,layerName:"WeatherRadar",icon:"radar",minZoom:0,isLicensed:!0},{id:"weathercloud",name:"Weather Clouds",isVisible:!1,isLoaded:!1,layerName:"WeatherCloud",icon:"cloud",minZoom:0,isLicensed:!0},{id:"weatheralert",name:"Weather Alerts",isVisible:!1,isLoaded:!1,layerName:"WeatherAlert",icon:"alerts",minZoom:0,isLicensed:!0},{id:"roadsurface",name:"Weather Road Surface",isVisible:!1,isLoaded:!1,layerName:"RoadSurface",icon:"surfaces",minZoom:1,isLicensed:!0},{id:"truckrestriction",name:"Truck Restrictions",isVisible:!1,isLoaded:!1,layerName:"TruckRestriction",icon:"restrictions",minZoom:14,isLicensed:!0},{id:"customroad",name:"Custom Roads",isVisible:!1,isLoaded:!1,layerName:"CustomRoad",icon:"customroad",minZoom:4,isLicensed:!1},{id:"building3d",name:"3D Buildings",isVisible:!1,isLoaded:!1,layerName:"3dBuilding",icon:"3d_buildings",minZoom:14,isLicensed:!0},{id:"pointsofinterest",name:"Points of Interest",isVisible:!1,isLoaded:!1,layerName:"PointsOfInterest",icon:"poi",minZoom:12,isLicensed:!0},{id:"places",name:"Places",isVisible:!1,isLoaded:!1,layerName:"Places",icon:"places",minZoom:12,isLicensed:!0}],a=function(){function e(){this.mapHandlers=new Map}return e.prototype.setMap=function(e){this.map=e},e.prototype.add=function(e){if(this.map){this.map.on(e.eventName,e.listener);var t=e.eventName+Date.now();return this.mapHandlers.set(t,e),t}console.warn("Handler cannot be added. The map has not been set for this manager.")},e.prototype.remove=function(e){var t=this.mapHandlers.get(e);this.map.off(t.eventName,t.listener),this.mapHandlers.delete(e)},e.prototype.removeAll=function(){var e=this;this.mapHandlers.forEach((function(t){e.map.off(t.eventName,t.listener)})),this.mapHandlers.clear()},e}(),n={STYLE_URL:"https://tiles.alk.com/styles/"};var l={showContentLayers:!0,showBaseStyles:!0,showCustomStyles:!1,showMobileStyles:!1,hideLayers:[],hideStyles:[]},o=function(){function e(e){var t=this;this._mapHandlerManager=new a,this._mapBasedContentLayers=["building3d","places"],this._urls=n,this._options=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var s=0,a=t;s<a.length;s++){var n=a[s];for(var l in n)e[l]=n[l]}return e}({},l,e),this._hasStyles=this._options.showBaseStyles||this._options.showCustomStyles||this._options.showMobileStyles,this._hasLayers=this._options.showContentLayers,this._outsideClickListener=function(e){var i,s;t._container.contains(e.target)||(null===(i=t._styleMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open"),null===(s=t._layerMenu)||void 0===s||s.classList.remove("trimblemaps-menu-container-open"))}}return e.prototype.onAdd=function(e){var t=this;this._map=e,this._mapHandlerManager.setMap(this._map),this._container=document.createElement("div"),this._container.className="trimblemaps-ctrl trimblemaps-ctrl-group trimblemaps-menu-ctrl";var i=document.createElement("button");i.className="trimblemaps-ctrl-icon trimblemaps-menu-styles-button",i.title="Map styles",i.type="button",i.addEventListener("click",(function(){t._toggleStyleMenu()}));var s=document.createElement("button");s.className="trimblemaps-ctrl-icon trimblemaps-menu-layers-button",s.title="Content layers",s.type="button",s.addEventListener("click",(function(){t._toggleLayerMenu()}));var a=document.createElement("div");a.className="trimblemaps-menu-container";var n=document.createElement("div");n.className="trimblemaps-menu-arrow",a.appendChild(n);var l=document.createElement("h5");l.className="trimblemaps-menu-title";var o=document.createElement("div");if(o.className="trimblemaps-menu-list",this._hasStyles&&(this._styleMenu=a.cloneNode(!0),this._styleList=o.cloneNode(!0),l.innerHTML="Map styles",this._styleMenu.appendChild(l.cloneNode(!0)),this._styleMenu.appendChild(this._styleList),this._styleMenu.classList.add("trimblemaps-menu-map-styles"),this._container.appendChild(i),this._container.appendChild(this._styleMenu),this._container.classList.add("trimblemaps-menu-has-styles"),this._getStyles()),this._hasLayers){this._layerMenu=a.cloneNode(!0),this._layerList=o.cloneNode(!0),l.innerHTML="Content layers",this._layerMenu.appendChild(l.cloneNode(!0)),this._layerMenu.appendChild(this._layerList),this._layerMenu.classList.add("trimblemaps-menu-content-layers"),this._hasStyles?this._container.insertBefore(s,this._container.childNodes[1]):this._container.appendChild(s),this._container.appendChild(this._layerMenu),this._container.classList.add("trimblemaps-menu-has-layers");var r=document.createElement("div");r.className="trimblemaps-menu-divider",this._layerList.appendChild(r),this._map.once("load",(function(){t._setLayerZoomState()})),this._map.on("zoomend",(function(){t._setLayerZoomState()}))}return this._initializeLayers(),document.addEventListener("click",this._outsideClickListener),this._container},e.prototype.onRemove=function(){var e=this;this._map&&(document.removeEventListener("click",this._outsideClickListener),this._container.parentNode.removeChild(this._container),this._mapHandlerManager.removeAll(),this._contentLayers.forEach((function(t){t.isLoaded&&(e._mapBasedContentLayers.includes(t.id)?e._map["set".concat(t.layerName,"Visibility")](!1):t.layerInstance.remove())})),this._contentLayers=[],this._map=void 0)},e.prototype._getStyles=function(){var e=this,t="".concat(this._urls.STYLE_URL,"getstylemetadatalist?version=v4&key=").concat(i.default.APIKey);fetch(t).then((function(e){return e.json()})).then((function(t){var i=t,s=document.createElement("div");s.className="trimblemaps-menu-divider";var a=i.filter((function(t){return"base"===t.styleType&&!t.displayName.startsWith("Mobile")&&!t.displayName.startsWith("Simple")&&!e._options.hideStyles.includes(t.displayName)})).sort((function(e,t){return e.displayName>t.displayName?-1:1})),n=i.filter((function(t){return"base"===t.styleType&&t.displayName.startsWith("Mobile")&&!e._options.hideStyles.includes(t.displayName)})),l=i.filter((function(t){return"custom"===t.styleType&&!e._options.hideStyles.includes(t.displayName)})).sort((function(e,t){return e.displayName>t.displayName?1:-1}));e._options.showBaseStyles&&(e._styleList.appendChild(s.cloneNode(!0)),a.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showMobileStyles&&(e._styleList.appendChild(s.cloneNode(!0)),n.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showCustomStyles&&(e._styleList.appendChild(s.cloneNode(!0)),l.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._map.once("styledata",(function(){var t=e._map.style.stylesheet.id.replace("alk_","");e._setSelectedStyle(t)}))}))},e.prototype._initializeLayers=function(){var e=this;this._contentLayers=s.map((function(t){var i=Object.assign({},t);if(e._hasLayers&&!e._options.hideLayers.includes(t.name)&&t.isLicensed){var s=document.createElement("div");if(s.className="trimblemaps-menu-item trimblemaps-menu-layer-item","places"===i.id){var a=e._map.version.split(".");parseFloat("".concat(a[0],".").concat(a[1]))>=3.8&&(i.isVisible=!0,s.classList.add("trimblemaps-item-selected"))}s.setAttribute("data-layer-id",i.id),s.setAttribute("data-layer-name",i.name),s.setAttribute("data-layer-minzoom",i.minZoom.toString()),s.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(i.icon,'"></span>\n ').concat(i.name,"\n "),s.addEventListener("click",(function(){e.setContentLayerVisibility(i.name)})),e._layerList.appendChild(s),i.element=s}return i}))},e.prototype._toggleStyleMenu=function(){var e,t;null===(e=this._styleMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._layerMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleLayerMenu=function(){var e,t;null===(e=this._layerMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._styleMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open")},e.prototype._setStyle=function(e){var t=this._getId(e);t!==this._styleList.querySelector(".trimblemaps-item-selected").getAttribute("data-style-id")&&("base"===e.styleType?this._map.setStyle(t):"custom"===e.styleType&&this._map.setStyle("trimblemaps://styles/".concat(t)),this._setSelectedStyle(t)),this._toggleStyleMenu()},e.prototype._setSelectedStyle=function(e){this._styleList.querySelectorAll(".trimblemaps-menu-style-item").forEach((function(t){t.getAttribute("data-style-id")===e?t.classList.add("trimblemaps-item-selected"):t.classList.remove("trimblemaps-item-selected")}))},e.prototype._setLayer=function(e){var t=this;this._setSelectedLayer(e.id),setTimeout((function(){var e;null===(e=t._layerMenu)||void 0===e||e.classList.remove("trimblemaps-menu-container-open")}),350)},e.prototype._setSelectedLayer=function(e){var t;null===(t=this._layerList)||void 0===t||t.querySelectorAll(".trimblemaps-menu-layer-item").forEach((function(t){t.getAttribute("data-layer-id")===e&&t.classList.toggle("trimblemaps-item-selected")}))},e.prototype._setLayerZoomState=function(){var e=this;document.querySelectorAll(".trimblemaps-menu-layer-item").forEach((function(t){var i=parseInt(t.getAttribute("data-layer-minzoom"));e._map.getZoom()>=i?(t.classList.remove("trimblemaps-menu-item-disabled"),t.removeAttribute("title")):(t.classList.add("trimblemaps-menu-item-disabled"),t.setAttribute("title","Does not display until zoom level ".concat(i)))}))},e.prototype._getId=function(e){return e.styleName.split(".")[0]},e.prototype._getThumbnail=function(e,t,i){var s=document.createElement("span");return s.className="trimblemaps-menu-thumbnail",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" xml:space="preserve">\n <path fill="'.concat(e,'" d="M0 0h32v32H0z"/>\n <path fill="').concat(t,'" d="M6 32c1.04-1.44 2.74-3.33 5.36-4.45 1.62-.69 1.93-.39 3.34-1.1 2.45-1.23 2.59-2.7 5.69-5.86 2.45-2.5 2.68-1.9 3.92-3.58 1.83-2.47 1.44-3.91 2.93-6.4C28.02 9.29 29.4 7.56 32 6v26H6z"/>\n <path fill="none" stroke="').concat(i,'" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M-.07 24.79c.97-.46 2.3-1.15 3.8-2.09 1.96-1.23 3.75-2.61 6.14-4.79 4.23-3.87 4.83-5.25 8.51-8.71 2.18-2.05 3.55-2.47 5.62-4.71A28.05 28.05 0 0 0 27.36 0"/>\n <path fill="none" stroke="').concat(i,'" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M11.23 16.74c-2.18-2.57-3.43-4.88-4.19-6.58-.69-1.55-.95-2.57-1.93-3.78C3.6 4.52 1.55 3.66-.01 3.21"/>\n </svg>'),s},e.prototype._getStyleItem=function(e){var t=this,i=document.createElement("div");return i.className="trimblemaps-menu-item trimblemaps-menu-style-item",i.appendChild(this._getThumbnail(e.thumbnailLandColor,e.thumbnailWaterColor,e.thumbnailRoadColor)),i.appendChild(document.createTextNode(e.displayName)),i.setAttribute("data-style-id",this._getId(e)),i.setAttribute("data-style-name",e.displayName),i.addEventListener("click",(function(){t._setStyle(e)})),i},e.prototype._setServiceUrls=function(e){var t=this;Object.keys(this._urls).forEach((function(i){void 0!==e[i]&&(t._urls[i]=e[i])}))},e.prototype.setContentLayerVisibility=function(e,t){var s=this;if(null!==this._map){var a=this._contentLayers.find((function(t){return t.name===e}));if(a){if(a.isVisible!==t)return this._setLayer(a),a.isVisible=t||!a.isVisible,this._mapBasedContentLayers.includes(a.id)?(a.isLoaded||(a.layerHandlerId=this._mapHandlerManager.add({eventName:"style.load",listener:function(){s._map["set".concat(a.layerName,"Visibility")](a.isVisible)}}),a.isLoaded=!0),this._map.isStyleLoaded()&&this._map["set".concat(a.layerName,"Visibility")](a.isVisible),a.isVisible):(a.isLoaded?a.layerInstance.setVisibility(a.isVisible):(a.layerInstance=new i.default[a.layerName],this._map.isStyleLoaded()?a.layerInstance.addTo(this._map):this._map.once("style.load",(function(){a.layerInstance.addTo(s._map)})),a.layerHandlerId=this._mapHandlerManager.add({eventName:a.id,listener:function(){a.isLoaded=!0,a.layerInstance.setVisibility(a.isVisible)}})),a.isVisible)}else console.warn("".concat(e," is not a valid content layer name."))}else console.warn("This control must be added to a map before content layer visibility can be set.")},e}();return o})); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31735
318
2