Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trimblemaps/trimblemaps-mapmenus

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trimblemaps/trimblemaps-mapmenus - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

package.json
{
"name": "@trimblemaps/trimblemaps-mapmenus",
"version": "1.0.6",
"version": "1.0.7",
"description": "Map control for switching map styles in the JavaScript Maps SDK.",

@@ -5,0 +5,0 @@ "main": "trimblemaps-mapmenus.js",

@@ -5,2 +5,9 @@ # @trimblemaps/trimblemaps-mapmenus

![Map Menus Screenshot](https://developer.trimblemaps.com/maps-sdk/img/examples/map-menu.png)
- [Documentation](https://developer.trimblemaps.com/maps-sdk/guide/add-ons/map-menus/)
- [Demo](https://developer.trimblemaps.com/maps-sdk/examples/map-menu/)
- [Release Notes](https://developer.trimblemaps.com/maps-sdk/release-notes/)
- [License](https://developer.trimblemaps.com/maps-sdk/legal/license/)
See the [Trimble MAPS Developer Portal](https://developer.trimblemaps.com/maps-sdk/) for more information.

@@ -58,2 +58,3 @@ import TrimbleMaps from '@trimblemaps/trimblemaps-js';

private _weatherSpecializedLayerInstance?;
private _mapRegionLayerList;
private _mapBasedContentLayers;

@@ -100,5 +101,5 @@ private _weatherContentLayers;

*/
setWeatherSpecializedLayerVisibility(isVisible?: boolean, layerName?: string): boolean;
setWeatherSpecializedLayerVisibility(layerName?: string, isVisible?: boolean): boolean;
}
export { MapMenus as default };

@@ -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),a=[{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:"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:"customroads",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}],s=[{id:"weatherradar",name:"Doppler Radar",isVisible:!1,isLoaded:!1,layerName:"WeatherRadar",icon:"radar_icon",minZoom:0,isLicensed:!0},{id:"weathercloud",name:"Visible Clouds",isVisible:!1,isLoaded:!1,layerName:"WeatherCloud",icon:"cloud_icon",minZoom:0,isLicensed:!0},{id:"weatheralert",name:"Weather Alerts (US & Can.)",isVisible:!1,isLoaded:!1,layerName:"WeatherAlert",icon:"weather_alerts_icon",minZoom:0,isLicensed:!0},{id:"satellite_infrared_color",name:"Satellite Infrared Radar",isVisible:!1,isLoaded:!1,layerName:"weather_infrared",icon:"infrared_radar_icon",minZoom:0,isLicensed:!0},{id:"tropical_cyclones_names",name:"Tropical Cyclones",isVisible:!1,isLoaded:!1,layerName:"weather_cyclone",icon:"hurricane_icon",minZoom:0,isLicensed:!0},{id:"stormcells",name:"Storm Cells",isVisible:!1,isLoaded:!1,layerName:"weather_stormcell",icon:"thunderstorm_icon",minZoom:0,isLicensed:!0},{id:"lightning_strikes",name:"Lightning Strikes",isVisible:!1,isLoaded:!1,layerName:"weather_lightning",icon:"bolt_icon",minZoom:0,isLicensed:!0},{id:"wind_speeds",name:"Wind Speeds",isVisible:!1,isLoaded:!1,layerName:"weather_wind",icon:"wind_icon",minZoom:0,isLicensed:!0},{id:"wind_dir",name:"Wind Direction",isVisible:!1,isLoaded:!1,layerName:"weather_winddir",icon:"wind_dir_icon",minZoom:0,isLicensed:!0},{id:"fwind_speeds",name:"Wind Speeds",isVisible:!1,isLoaded:!1,layerName:"weather_fwind",icon:"wind_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures",name:"Temperatures",isVisible:!1,isLoaded:!1,layerName:"weather_ftemp",icon:"temperature_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures_max",name:"High Temperatures (US)",isVisible:!1,isLoaded:!1,layerName:"weather_ftempmax",icon:"thermometer_hot_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures_min",name:"Low Temperatures (US)",isVisible:!1,isLoaded:!1,layerName:"weather_ftempmin",icon:"thermometer_cold_icon",minZoom:0,isLicensed:!0},{id:"fqsf_accum",isVisible:!1,name:"Snow Accumulation",isLoaded:!1,layerName:"weather_fsnow",icon:"accumulation_icon",minZoom:0,isLicensed:!0}],n=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}(),r={STYLE_URL:"https://tiles.alk.com/styles/"};function o(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var a=0,s=t;a<s.length;a++){var n=s[a];for(var r in n)e[r]=n[r]}return e}var l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},l(e,t)};"function"==typeof SuppressedError&&SuppressedError;var m={layerId:"Weather",isVisible:!0},c=function(e){function t(t,i,a){var s=this,n=o({},m,a);return(s=e.call(this,n)||this)._urls=r,s._layerNames=[],s._map=t,s._mapmenuControl=i,s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t.prototype._getContent=function(){var e=this,t="".concat(this._urls.STYLE_URL,"v5/").concat(this._map.getRegion(),"/").concat(this._map.getStyleName(),"/").concat(this._options.layerId,"?key=").concat(i.default.APIKey||"");this._layerNames=[],fetch(t).then((function(t){return e._map.fire("weatherlayersloading"),t.json()})).then((function(t){if(t.sources){for(var i in t.sources)e._map.getSource(i)||e._map.addSource(i,t.sources[i]);t.layers.length&&(t.layers.forEach((function(t){var i="".concat(t.id);e._layerNames.push(i),t.id=i;var a="places_point_basic";void 0!==t.metadata&&void 0!==t.metadata.beforeLayer&&(a=t.metadata.beforeLayer),e._map.getLayer(a)?e._map.addLayer(t,a):e._map.addLayer(t)})),setTimeout((function(e){e._options.layerName&&e._map.setLayoutProperty("".concat(e._options.layerName),"visibility",e._options.isVisible?"visible":"none")}),350,e)),e._map.fire("weatherlayersloaded")}else console.warn(null==t?void 0:t.name)}))},t}(e.ContentBase),d={showContentLayers:!0,showWeatherLayers:!0,showBaseStyles:!0,showCustomStyles:!1,showMobileStyles:!1,hideLayers:[],hideStyles:[]};return function(){function e(e){var t=this;this._mapHandlerManager=new n,this._mapBasedContentLayers=["building3d","places"],this._weatherContentLayers=["WeatherRadar","WeatherCloud","WeatherAlert"],this._urls=r,this._options=o({},d,e),this._hasStyles=this._options.showBaseStyles||this._options.showCustomStyles||this._options.showMobileStyles,this._hasLayers=this._options.showContentLayers,this._hasWeather=this._options.showWeatherLayers,this._outsideClickListener=function(e){var i,a,s;t._container.contains(e.target)||(null===(i=t._styleMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open"),null===(a=t._layerMenu)||void 0===a||a.classList.remove("trimblemaps-menu-container-open"),null===(s=t._weatherMenu)||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 a=document.createElement("button");a.className="trimblemaps-ctrl-icon trimblemaps-menu-layers-button",a.title="Content layers",a.type="button",a.addEventListener("click",(function(){t._toggleLayerMenu()}));var s=document.createElement("button");s.className="trimblemaps-ctrl-icon trimblemaps-menu-weather-button",s.title="Weather layers",s.type="button",s.addEventListener("click",(function(){t._toggleWeatherMenu()}));var n=document.createElement("div");n.className="trimblemaps-menu-container";var r=document.createElement("div");r.className="trimblemaps-menu-arrow",n.appendChild(r);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=n.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._container.classList.add("trimblemaps-menu-has-styles"),this._getStyles()),this._hasLayers){this._layerMenu=n.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(a,this._container.childNodes[1]):this._container.appendChild(a),this._container.appendChild(this._layerMenu),this._container.classList.add("trimblemaps-menu-has-layers");var m=document.createElement("div");m.className="trimblemaps-menu-divider",this._layerList.appendChild(m)}return this._hasWeather&&(this._weatherMenu=n.cloneNode(!0),this._weatherList=l.cloneNode(!0),o.innerHTML="Weather layers",this._weatherMenu.appendChild(o.cloneNode(!0)),this._weatherMenu.appendChild(this._weatherList),this._weatherMenu.classList.add("trimblemaps-menu-weather-layers"),this._hasStyles&&this._hasLayers?this._container.insertBefore(s,this._container.childNodes[2]):this._hasStyles||this._hasLayers?this._container.insertBefore(s,this._container.childNodes[1]):this._container.appendChild(s),this._container.appendChild(this._weatherMenu),this._container.classList.add("trimblemaps-menu-has-weather")),this._initializeLayers(),this._initializeWeatherLayers(),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._weatherLayers.forEach((function(t){t.isLoaded&&e._weatherContentLayers.includes(t.layerName)&&t.layerInstance.remove()})),this._weatherSpecializedLayerInstance&&(this._weatherSpecializedLayerInstance.remove(),this._weatherSpecializedLayerInstance=void 0),this._contentLayers=[],this._weatherLayers=[],this._map=void 0)},e.prototype._getStyles=function(){var e=this,t="".concat(this._urls.STYLE_URL,"getstylemetadatalist?version=v5&key=").concat(i.default.APIKey);fetch(t).then((function(e){return e.json()})).then((function(t){var i=t,a=document.createElement("div");a.className="trimblemaps-menu-divider";var s=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)})),r=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(a.cloneNode(!0)),s.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showMobileStyles&&(e._styleList.appendChild(a.cloneNode(!0)),n.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showCustomStyles&&(e._styleList.appendChild(a.cloneNode(!0)),r.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._map.once("styledata",(function(){e._setSelectedStyle()})),e._map.on("style.load",(function(){e._setSelectedStyle()})),e._map.on("idle",(function(){e._setSelectedStyle()}))})).catch((function(t){var i=document.createElement("span");i.className="trimblemaps-mm-ml-1",i.innerHTML='<p style="margin: 0.75rem; ">Get access to view Map Styles.</p>';var a=document.createElement("div");a.className="trimblemaps-menu-divider",e._styleList.appendChild(a),e._styleList.appendChild(i),console.warn(t)}))},e.prototype._initializeLayers=function(){var e,t=this,s="".concat(this._urls.STYLE_URL,"contentlayers/").concat(this._map.getRegion(),"?key=").concat(i.default.APIKey||"");fetch(s).then((function(e){if(!e.ok)throw new Error("HTTP status "+e.status);return e.text()})).then((function(i){if(e=i.indexOf(",")>-1?i.split(","):[],t._contentLayers=a.map((function(i){var a=Object.assign({},i);if((null==e?void 0:e.length)>0){var s=e.find((function(e){return e===i.id}));i.isLicensed=!!s}else i.isLicensed=!1;if(t._hasLayers&&!t._options.hideLayers.includes(i.name)&&i.isLicensed){var n=document.createElement("div");if(n.className="trimblemaps-menu-item trimblemaps-menu-layer-item","places"===a.id){var r=t._map.version.split(".");parseInt(r[1])>=8&&(a.isVisible=!0,n.classList.add("trimblemaps-item-selected"))}n.setAttribute("data-layer-id",a.id),n.setAttribute("data-layer-name",a.name),n.setAttribute("data-layer-minzoom",a.minZoom.toString()),n.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(a.icon,'"></span>\n ').concat(a.name,"\n ");var o=document.createElement("div");o.className="trimblemaps-mapmenus-custom-control trimblemaps-mapmenus-custom-switch trimblemaps-mapmenus-custom-control-inline",document.createElement("div").className="result-info text-ellipsis flex-element";var l=document.createElement("label");l.className="trimblemaps-mapmenus-custom-control-label",l.setAttribute("for","switch_"+a.id);var m=document.createElement("INPUT");m.className="trimblemaps-mapmenus-custom-control-input",m.setAttribute("type","checkbox"),m.setAttribute("role","switch"),m.setAttribute("id","switch_"+a.id),m.setAttribute("data-mapmenus-id",a.id),m.setAttribute("data-mapmenus-name",a.name),m.setAttribute("aria-label",a.name),m.removeAttribute("checked"),"places"===a.id&&a.isVisible&&m.setAttribute("checked","true"),m.addEventListener("change",(function(e){var i=e.target.checked;t.setContentLayerVisibility(a.name),t._map.fire("layervisibilitychange",{layerId:a.id,isSelected:i})})),o.appendChild(m),o.appendChild(l),n.appendChild(o);var c=document.createElement("div"),d=document.createElement("span");document.querySelector(".trimblemaps-ctrl-top-left > div.trimblemaps-menu-ctrl")||document.querySelector(".trimblemaps-ctrl-bottom-left > div.trimblemaps-menu-ctrl")?c.classList.add("trimblemaps-mapmenus-tooltip-left"):c.classList.add("trimblemaps-mapmenus-tooltip"),d.classList.add("trimblemaps-mapmenus-tooltiptext"),d.innerHTML="Display starts at zoom level ".concat(a.minZoom),c.appendChild(d.cloneNode(!0)),n.appendChild(c),n.addEventListener("mouseover",(function(e){e.currentTarget.querySelector(".trimblemaps-mapmenus-tooltiptext").style.visibility="visible"})),n.addEventListener("mouseout",(function(e){e.currentTarget.querySelector(".trimblemaps-mapmenus-tooltiptext").style.visibility="hidden"})),t._layerList.appendChild(n),a.element=n}return a})),(null==e?void 0:e.length)<=0){var s=document.createElement("span");s.className="trimblemaps-mm-ml-1",s.innerHTML='<p style="margin: 0.75rem; ">Get access to view Content Layers.</p>',t._layerList.appendChild(s)}})).catch((function(e){var i=document.createElement("span");i.className="trimblemaps-mm-ml-1",i.innerHTML='<p style="margin: 0.75rem; ">Get access to view Content Layers.</p>',t._layerList.appendChild(i),console.warn(e)}))},e.prototype._initializeWeatherLayers=function(){var e=this;this._weatherLayers=s.map((function(t){var i=Object.assign({},t),a=e._createWeatherItem(i);if("fwind_speeds"===i.id){var s=document.createElement("h6");s.className="trimblemaps-menu-heading",s.innerHTML="Forecasts",e._weatherList.appendChild(s)}return e._weatherList.appendChild(a),i.element=a,i}))},e.prototype._createWeatherItem=function(e){var t=this,i=document.createElement("div");i.className="trimblemaps-menu-item trimblemaps-menu-layer-item",i.setAttribute("data-layer-id",e.id),i.setAttribute("data-layer-name",e.name),i.setAttribute("data-layer-minzoom",e.minZoom.toString()),i.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(e.icon,'"></span>\n ').concat(e.name,"\n ");var a=document.createElement("div");a.className="trimblemaps-mapmenus-custom-control trimblemaps-mapmenus-custom-switch trimblemaps-mapmenus-custom-control-inline",document.createElement("div").className="result-info text-ellipsis flex-element";var s=document.createElement("label");s.className="trimblemaps-mapmenus-custom-control-label",s.setAttribute("for","switch_"+e.id);var n=document.createElement("INPUT");return n.className="trimblemaps-mapmenus-custom-control-input",n.setAttribute("type","checkbox"),n.setAttribute("id","switch_"+e.id),n.setAttribute("data-mapmenus-id",e.id),n.setAttribute("data-mapmenus-name",e.name),e.isVisible?n.setAttribute("checked","checked"):n.removeAttribute("checked"),n.addEventListener("change",(function(i){var a=i.target.checked;t._weatherContentLayers.includes(e.layerName)?t.setContentLayerVisibility(e.layerName,void 0,!0):t.setWeatherSpecializedLayerVisibility(a,e.layerName),t._map.fire("layervisibilitychange",{layerId:e.layerName,isSelected:a})})),a.appendChild(n),a.appendChild(s),i.appendChild(a),i},e.prototype._getMapMenusRequestInit=function(){var e=i.default.TIDToken,t=e.tidToken,a=e.externalAccountId,s=i.default.APIToken?i.default.APIToken.includes("token")?i.default.APIToken:"token=".concat(i.default.APIToken):void 0,n={headers:{"Content-Type":"application/json"}};return t&&(n.headers.tidtoken="".concat(t)),a&&(n.headers.extacctid="".concat(a)),t||(n.headers.Authorization=s?"".concat(s):i.default.APIKey),n},e.prototype._toggleStyleMenu=function(){var e,t,i;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"),null===(i=this._weatherMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleLayerMenu=function(){var e,t,i;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"),null===(i=this._weatherMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleWeatherMenu=function(){var e,t,i;null===(e=this._weatherMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._styleMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open"),null===(i=this._layerMenu)||void 0===i||i.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/v5/".concat(t)),this._setSelectedStyle(t)),this._toggleStyleMenu()},e.prototype._setSelectedStyle=function(e){var t;e||(e=(null===(t=this._map.style.stylesheet.id)||void 0===t?void 0:t.replace("alk_",""))||this._map.style.stylesheet.metadata.filename),this._styleList.querySelectorAll(".trimblemaps-menu-style-item").forEach((function(t){t.getAttribute("data-style-id")===e?(t.classList.add("trimblemaps-item-selected"),t.setAttribute("aria-selected","true")):(t.classList.remove("trimblemaps-item-selected"),t.setAttribute("aria-selected","false"))}))},e.prototype._setLayer=function(e){this._setSelectedLayer(e.id),setTimeout((function(){}),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._getId=function(e){return e.styleName.split(".")[0]},e.prototype._getThumbnail=function(e,t,i){var a=document.createElement("span");return a.className="trimblemaps-menu-thumbnail",a.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>'),a},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("role","button"),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,a){var s=this;if(null!==this._map){var n=a?this._weatherLayers.find((function(t){return t.layerName===e})):this._contentLayers.find((function(t){return t.name===e}));if(n){if(n.isVisible!==t){this._setLayer(n),n.isVisible=t||!n.isVisible;var r=document.querySelector("#switch_".concat(n.id));return n.isVisible?r.setAttribute("checked","true"):r.removeAttribute("checked"),this._mapBasedContentLayers.includes(n.id)?(n.isLoaded||(n.layerHandlerId=this._mapHandlerManager.add({eventName:"style.load",listener:function(){s._map["set".concat(n.layerName,"Visibility")](n.isVisible)}}),n.isLoaded=!0),void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded&&this._map["set".concat(n.layerName,"Visibility")](n.isVisible),n.isVisible):(n.isLoaded?n.layerInstance.setVisibility(n.isVisible):(n.layerInstance=new i.default[n.layerName],void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded?n.layerInstance.addTo(this._map):this._map.once("style.load",(function(){n.layerInstance.addTo(s._map)})),n.layerHandlerId=this._mapHandlerManager.add({eventName:n.id,listener:function(){n.isLoaded=!0,n.layerInstance.setVisibility(n.isVisible)}})),n.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.prototype.setWeatherSpecializedLayerVisibility=function(e,t){var i=this;if(null!==this._map)return this._weatherSpecializedLayerInstance?this._map.setLayoutProperty("".concat(t),"visibility",e?"visible":"none"):(this._weatherSpecializedLayerInstance=new c(this._map,this,{layerId:"Weather",isVisible:e,layerName:t}),void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded?this._weatherSpecializedLayerInstance.addTo(this._map):this._map.once("style.load",(function(){i._weatherSpecializedLayerInstance.addTo(i._map)}))),this._weatherSpecializedLayerInstance.isVisible();console.warn("This control must be added to a map before content layer visibility can be set.")},e}()}));
!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),a=[{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:"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:"customroads",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}],s=[{id:"weatherradar",name:"Doppler Radar",isVisible:!1,isLoaded:!1,layerName:"WeatherRadar",icon:"radar_icon",minZoom:0,isLicensed:!0},{id:"weathercloud",name:"Visible Clouds",isVisible:!1,isLoaded:!1,layerName:"WeatherCloud",icon:"cloud_icon",minZoom:0,isLicensed:!0},{id:"weatheralert",name:"Weather Alerts (US & Can.)",isVisible:!1,isLoaded:!1,layerName:"WeatherAlert",icon:"weather_alerts_icon",minZoom:0,isLicensed:!0},{id:"satellite_infrared_color",name:"Satellite Infrared Radar",isVisible:!1,isLoaded:!1,layerName:"weather_infrared",icon:"infrared_radar_icon",minZoom:0,isLicensed:!0},{id:"tropical_cyclones_names",name:"Tropical Cyclones",isVisible:!1,isLoaded:!1,layerName:"weather_cyclone",icon:"hurricane_icon",minZoom:0,isLicensed:!0},{id:"stormcells",name:"Storm Cells",isVisible:!1,isLoaded:!1,layerName:"weather_stormcell",icon:"thunderstorm_icon",minZoom:0,isLicensed:!0},{id:"lightning_strikes",name:"Lightning Strikes",isVisible:!1,isLoaded:!1,layerName:"weather_lightning",icon:"bolt_icon",minZoom:0,isLicensed:!0},{id:"wind_speeds",name:"Wind Speeds",isVisible:!1,isLoaded:!1,layerName:"weather_wind",icon:"wind_icon",minZoom:0,isLicensed:!0},{id:"wind_dir",name:"Wind Direction",isVisible:!1,isLoaded:!1,layerName:"weather_winddir",icon:"wind_dir_icon",minZoom:0,isLicensed:!0},{id:"fwind_speeds",name:"Wind Speeds",isVisible:!1,isLoaded:!1,layerName:"weather_fwind",icon:"wind_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures",name:"Temperatures",isVisible:!1,isLoaded:!1,layerName:"weather_ftemp",icon:"temperature_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures_max",name:"High Temperatures (US)",isVisible:!1,isLoaded:!1,layerName:"weather_ftempmax",icon:"thermometer_hot_icon",minZoom:0,isLicensed:!0},{id:"ftemperatures_min",name:"Low Temperatures (US)",isVisible:!1,isLoaded:!1,layerName:"weather_ftempmin",icon:"thermometer_cold_icon",minZoom:0,isLicensed:!0},{id:"fqsf_accum",isVisible:!1,name:"Snow Accumulation",isLoaded:!1,layerName:"weather_fsnow",icon:"accumulation_icon",minZoom:0,isLicensed:!0}],n=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}(),r={STYLE_URL:"https://tiles.alk.com/styles/"};function o(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var a=0,s=t;a<s.length;a++){var n=s[a];for(var r in n)e[r]=n[r]}return e}var l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},l(e,t)};"function"==typeof SuppressedError&&SuppressedError;var m={layerId:"Weather",isVisible:!0},c=function(e){function t(t,i,a){var s=this,n=o({},m,a);return(s=e.call(this,n)||this)._urls=r,s._layerNames=[],s._map=t,s._mapmenuControl=i,s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t.prototype._getContent=function(){var e=this,t="".concat(this._urls.STYLE_URL,"v5/").concat(this._map.getRegion(),"/").concat(this._map.getStyleName(),"/").concat(this._options.layerId,"?key=").concat(i.default.APIKey||"");this._layerNames=[],fetch(t).then((function(t){return e._map.fire("weatherlayersloading"),t.json()})).then((function(t){if(t.sources){for(var i in t.sources)e._map.getSource(i)||e._map.addSource(i,t.sources[i]);t.layers.length&&(t.layers.forEach((function(t){var i="".concat(t.id);e._layerNames.push(i),t.id=i;var a="places_point_basic";void 0!==t.metadata&&void 0!==t.metadata.beforeLayer&&(a=t.metadata.beforeLayer),e._map.getLayer(a)?e._map.addLayer(t,a):e._map.addLayer(t)})),setTimeout((function(e){e._options.layerName&&(e._map.setLayoutProperty("".concat(e._options.layerName),"visibility",e._options.isVisible?"visible":"none"),e._mapmenuControl._hasWeather&&e._mapmenuControl._weatherSpecializedLayerInstance&&e._mapmenuControl._weatherLayers.forEach((function(t){t.isVisible&&!e._mapmenuControl._weatherContentLayers.includes(t.layerName)&&e._map.setLayoutProperty("".concat(t.layerName),"visibility","visible")}))),e._map.fire("weatherlayersloaded")}),350,e))}else console.warn(null==t?void 0:t.name)}))},t}(e.ContentBase),d={showContentLayers:!0,showWeatherLayers:!0,showBaseStyles:!0,showCustomStyles:!1,showMobileStyles:!1,hideLayers:[],hideStyles:[]};return function(){function e(e){var t=this;this._mapHandlerManager=new n,this._mapBasedContentLayers=["building3d","places"],this._weatherContentLayers=["WeatherRadar","WeatherCloud","WeatherAlert"],this._urls=r,this._options=o({},d,e),this._hasStyles=this._options.showBaseStyles||this._options.showCustomStyles||this._options.showMobileStyles,this._hasLayers=this._options.showContentLayers,this._hasWeather=this._options.showWeatherLayers,this._outsideClickListener=function(e){var i,a,s;t._container.contains(e.target)||(null===(i=t._styleMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open"),null===(a=t._layerMenu)||void 0===a||a.classList.remove("trimblemaps-menu-container-open"),null===(s=t._weatherMenu)||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 a=document.createElement("button");a.className="trimblemaps-ctrl-icon trimblemaps-menu-layers-button",a.title="Content layers",a.type="button",a.addEventListener("click",(function(){t._toggleLayerMenu()}));var s=document.createElement("button");s.className="trimblemaps-ctrl-icon trimblemaps-menu-weather-button",s.title="Weather layers",s.type="button",s.addEventListener("click",(function(){t._toggleWeatherMenu()}));var n=document.createElement("div");n.className="trimblemaps-menu-container";var r=document.createElement("div");r.className="trimblemaps-menu-arrow",n.appendChild(r);var o=document.createElement("h5");o.className="trimblemaps-menu-title";var l=document.createElement("div");l.className="trimblemaps-menu-subtitle";var m=document.createElement("div");if(m.className="trimblemaps-menu-list",this._hasStyles&&(this._styleMenu=n.cloneNode(!0),this._styleList=m.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._container.classList.add("trimblemaps-menu-has-styles"),this._getStyles()),this._hasLayers){this._layerMenu=n.cloneNode(!0),this._layerList=m.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(a,this._container.childNodes[1]):this._container.appendChild(a),this._container.appendChild(this._layerMenu),this._container.classList.add("trimblemaps-menu-has-layers");var c=document.createElement("div");c.className="trimblemaps-menu-divider",this._layerList.appendChild(c)}return this._hasWeather&&(this._weatherMenu=n.cloneNode(!0),this._weatherList=m.cloneNode(!0),o.innerHTML="Weather layers",l.innerHTML="Display starts at zoom level 0",this._weatherMenu.appendChild(o.cloneNode(!0)),this._weatherMenu.appendChild(l.cloneNode(!0)),this._weatherMenu.appendChild(this._weatherList),this._weatherMenu.classList.add("trimblemaps-menu-weather-layers"),this._hasStyles&&this._hasLayers?this._container.insertBefore(s,this._container.childNodes[2]):this._hasStyles||this._hasLayers?this._container.insertBefore(s,this._container.childNodes[1]):this._container.appendChild(s),this._container.appendChild(this._weatherMenu),this._container.classList.add("trimblemaps-menu-has-weather")),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._weatherLayers.forEach((function(t){t.isLoaded&&e._weatherContentLayers.includes(t.layerName)&&t.layerInstance.remove()})),this._weatherSpecializedLayerInstance&&(this._weatherSpecializedLayerInstance.remove(),this._weatherSpecializedLayerInstance=void 0),this._contentLayers=[],this._weatherLayers=[],this._map=void 0)},e.prototype._getStyles=function(){var e=this,t="".concat(this._urls.STYLE_URL,"getstylemetadatalist?version=v5&key=").concat(i.default.APIKey);fetch(t).then((function(e){return e.json()})).then((function(t){var i=t,a=document.createElement("div");a.className="trimblemaps-menu-divider";var s=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)})),r=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(a.cloneNode(!0)),s.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showMobileStyles&&(e._styleList.appendChild(a.cloneNode(!0)),n.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._options.showCustomStyles&&(e._styleList.appendChild(a.cloneNode(!0)),r.forEach((function(t){e._styleList.appendChild(e._getStyleItem(t))}))),e._map.once("styledata",(function(){e._setSelectedStyle()})),e._map.on("style.load",(function(){e._setSelectedStyle()})),e._map.on("idle",(function(){e._setSelectedStyle()}))})).catch((function(t){var i=document.createElement("span");i.className="trimblemaps-mm-ml-1",i.innerHTML='<p style="margin: 0.75rem; ">Get access to view Map Styles.</p>';var a=document.createElement("div");a.className="trimblemaps-menu-divider",e._styleList.appendChild(a),e._styleList.appendChild(i),console.warn(t)}))},e.prototype._initializeLayers=function(){var e=this;this._mapRegionLayerList=[];var t="".concat(this._urls.STYLE_URL,"contentlayers/").concat(this._map.getRegion(),"?key=").concat(i.default.APIKey||"");fetch(t).then((function(e){if(!e.ok)throw new Error("HTTP status "+e.status);return e.text()})).then((function(t){var i;if(e._mapRegionLayerList=t.indexOf(",")>-1?t.split(","):[],e._contentLayers=a.map((function(t){var i,a=Object.assign({},t);if((null===(i=e._mapRegionLayerList)||void 0===i?void 0:i.length)>0){var s=e._mapRegionLayerList.find((function(e){return e===t.id}));t.isLicensed=!!s}else t.isLicensed=!1;if(e._hasLayers&&!e._options.hideLayers.includes(t.name)&&t.isLicensed){var n=document.createElement("div");if(n.className="trimblemaps-menu-item trimblemaps-menu-layer-item","places"===a.id){var r=e._map.version.split(".");parseInt(r[1])>=8&&(a.isVisible=!0,n.classList.add("trimblemaps-item-selected"))}n.setAttribute("data-layer-id",a.id),n.setAttribute("data-layer-name",a.name),n.setAttribute("data-layer-minzoom",a.minZoom.toString()),n.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(a.icon,'"></span>\n ').concat(a.name,"\n ");var o=document.createElement("div");o.className="trimblemaps-mapmenus-custom-control trimblemaps-mapmenus-custom-switch trimblemaps-mapmenus-custom-control-inline",document.createElement("div").className="result-info text-ellipsis flex-element";var l=document.createElement("label");l.className="trimblemaps-mapmenus-custom-control-label",l.setAttribute("for","switch_"+a.id);var m=document.createElement("INPUT");m.className="trimblemaps-mapmenus-custom-control-input",m.setAttribute("type","checkbox"),m.setAttribute("role","switch"),m.setAttribute("id","switch_"+a.id),m.setAttribute("data-mapmenus-id",a.id),m.setAttribute("data-mapmenus-name",a.name),m.setAttribute("aria-label",a.name),m.removeAttribute("checked"),"places"===a.id&&a.isVisible&&m.setAttribute("checked","true"),m.addEventListener("change",(function(t){var i=t.target.checked;e.setContentLayerVisibility(a.name),e._map.fire("layervisibilitychange",{layerId:a.id,isSelected:i})})),o.appendChild(m),o.appendChild(l),n.appendChild(o);var c=document.createElement("div"),d=document.createElement("span");document.querySelector(".trimblemaps-ctrl-top-left > div.trimblemaps-menu-ctrl")||document.querySelector(".trimblemaps-ctrl-bottom-left > div.trimblemaps-menu-ctrl")?c.classList.add("trimblemaps-mapmenus-tooltip-left"):c.classList.add("trimblemaps-mapmenus-tooltip"),d.classList.add("trimblemaps-mapmenus-tooltiptext"),d.innerHTML="Display starts at zoom level ".concat(a.minZoom),c.appendChild(d.cloneNode(!0)),n.appendChild(c),n.addEventListener("mouseover",(function(e){e.currentTarget.querySelector(".trimblemaps-mapmenus-tooltiptext").style.visibility="visible"})),n.addEventListener("mouseout",(function(e){e.currentTarget.querySelector(".trimblemaps-mapmenus-tooltiptext").style.visibility="hidden"})),e._layerList.appendChild(n),a.element=n}return a})),(null===(i=e._mapRegionLayerList)||void 0===i?void 0:i.length)<=0){var s=document.createElement("span");s.className="trimblemaps-mm-ml-1",s.innerHTML='<p style="margin: 0.75rem; ">Get access to view Content Layers.</p>',e._layerList.appendChild(s)}else e._hasWeather&&e._initializeWeatherLayers()})).catch((function(t){var i=document.createElement("span");i.className="trimblemaps-mm-ml-1",i.innerHTML='<p style="margin: 0.75rem; ">Get access to view Content Layers.</p>',e._layerList.appendChild(i),console.warn(t)}))},e.prototype._initializeWeatherLayers=function(){var e=this,t=this._map.getRegion();"na"!==t&&"ww"!==t&&(this._mapRegionLayerList=this._mapRegionLayerList.filter((function(e){return-1===["weather_ftempmax","weather_ftempmin"].indexOf(e)}))),this._weatherLayers=s.map((function(t){if(e._mapRegionLayerList.find((function(e){return e===t.layerName.toLowerCase()}))){var i=Object.assign({},t);if(!e._options.hideLayers.includes(i.name)){var a=e._createWeatherItem(i);if(i.id.startsWith("f")&&!e._weatherList.querySelector(".trimblemaps-menu-heading")){var s=document.createElement("h6");s.className="trimblemaps-menu-heading",s.innerHTML="Forecasts",e._weatherList.appendChild(s)}e._weatherList.appendChild(a),i.element=a}return i}})),this._weatherLayers=this._weatherLayers.filter((function(e){return void 0!==e})),this.setWeatherSpecializedLayerVisibility("weather_infrared"),setTimeout((function(){e._weatherList.querySelector(".trimblemaps-menu-layer-item")?document.querySelector(".trimblemaps-menu-weather-button")&&(document.querySelector(".trimblemaps-menu-weather-button").style.display="block"):document.querySelector(".trimblemaps-menu-weather-button")&&(document.querySelector(".trimblemaps-menu-weather-button").style.display="none")}))},e.prototype._createWeatherItem=function(e){var t=this,i=document.createElement("div");i.className="trimblemaps-menu-item trimblemaps-menu-layer-item",i.setAttribute("data-layer-id",e.id),i.setAttribute("data-layer-name",e.name),i.setAttribute("data-layer-minzoom",e.minZoom.toString()),i.innerHTML='\n <span class="trimblemaps-menu-thumbnail trimblemaps-menu-no-border trimblemaps-menu-'.concat(e.icon,'"></span>\n ').concat(e.name,"\n ");var a=document.createElement("div");a.className="trimblemaps-mapmenus-custom-control trimblemaps-mapmenus-custom-switch trimblemaps-mapmenus-custom-control-inline",document.createElement("div").className="result-info text-ellipsis flex-element";var s=document.createElement("label");s.className="trimblemaps-mapmenus-custom-control-label",s.setAttribute("for","switch_"+e.id);var n=document.createElement("INPUT");return n.className="trimblemaps-mapmenus-custom-control-input",n.setAttribute("type","checkbox"),n.setAttribute("role","switch"),n.setAttribute("id","switch_"+e.id),n.setAttribute("data-mapmenus-id",e.id),n.setAttribute("data-mapmenus-name",e.name),n.setAttribute("aria-label",e.name),e.isVisible?n.setAttribute("checked","checked"):n.removeAttribute("checked"),n.addEventListener("change",(function(i){var a=i.target.checked;t._weatherContentLayers.includes(e.layerName)?t.setContentLayerVisibility(e.layerName,void 0,!0):(t._weatherLayers.map((function(t){t.layerName===e.layerName&&(t.isVisible=a)})),t.setWeatherSpecializedLayerVisibility(e.layerName,a)),t._map.fire("layervisibilitychange",{layerId:e.layerName,isSelected:a})})),a.appendChild(n),a.appendChild(s),i.appendChild(a),this._layerList.appendChild(i),e.element=i,i},e.prototype._getMapMenusRequestInit=function(){var e=i.default.TIDToken,t=e.tidToken,a=e.externalAccountId,s=i.default.APIToken?i.default.APIToken.includes("token")?i.default.APIToken:"token=".concat(i.default.APIToken):void 0,n={headers:{"Content-Type":"application/json"}};return t&&(n.headers.tidtoken="".concat(t)),a&&(n.headers.extacctid="".concat(a)),t||(n.headers.Authorization=s?"".concat(s):i.default.APIKey),n},e.prototype._toggleStyleMenu=function(){var e,t,i;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"),null===(i=this._weatherMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleLayerMenu=function(){var e,t,i;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"),null===(i=this._weatherMenu)||void 0===i||i.classList.remove("trimblemaps-menu-container-open")},e.prototype._toggleWeatherMenu=function(){var e,t,i;null===(e=this._weatherMenu)||void 0===e||e.classList.toggle("trimblemaps-menu-container-open"),null===(t=this._styleMenu)||void 0===t||t.classList.remove("trimblemaps-menu-container-open"),null===(i=this._layerMenu)||void 0===i||i.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/v5/".concat(t)),this._setSelectedStyle(t)),this._toggleStyleMenu()},e.prototype._setSelectedStyle=function(e){var t;e||(e=(null===(t=this._map.style.stylesheet.id)||void 0===t?void 0:t.replace("alk_",""))||this._map.style.stylesheet.metadata.filename),this._styleList.querySelectorAll(".trimblemaps-menu-style-item").forEach((function(t){t.getAttribute("data-style-id")===e?(t.classList.add("trimblemaps-item-selected"),t.setAttribute("aria-selected","true")):(t.classList.remove("trimblemaps-item-selected"),t.setAttribute("aria-selected","false"))}))},e.prototype._setLayer=function(e){this._setSelectedLayer(e.id),setTimeout((function(){}),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._getId=function(e){return e.styleName.split(".")[0]},e.prototype._getThumbnail=function(e,t,i){var a=document.createElement("span");return a.className="trimblemaps-menu-thumbnail",a.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>'),a},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("role","button"),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,a){var s=this;if(null!==this._map){var n=a?this._weatherLayers.find((function(t){return t.layerName===e})):this._contentLayers.find((function(t){return t.name===e}));if(n){if(n.isVisible!==t){this._setLayer(n),n.isVisible=t||!n.isVisible;var r=document.querySelector("#switch_".concat(n.id));return n.isVisible?r.setAttribute("checked","true"):r.removeAttribute("checked"),this._mapBasedContentLayers.includes(n.id)?(n.isLoaded||(n.layerHandlerId=this._mapHandlerManager.add({eventName:"style.load",listener:function(){s._map["set".concat(n.layerName,"Visibility")](n.isVisible)}}),n.isLoaded=!0),void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded&&this._map["set".concat(n.layerName,"Visibility")](n.isVisible),n.isVisible):(n.isLoaded?n.layerInstance.setVisibility(n.isVisible):(n.layerInstance=new i.default[n.layerName],void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded?n.layerInstance.addTo(this._map):this._map.once("style.load",(function(){n.layerInstance.addTo(s._map)})),n.layerHandlerId=this._mapHandlerManager.add({eventName:n.id,listener:function(){n.isLoaded=!0,n.layerInstance.setVisibility(n.isVisible)}})),n.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.prototype.setWeatherSpecializedLayerVisibility=function(e,t){var i=this;if(null!==this._map){var a=this._weatherLayers.find((function(t){return t.layerName===e})),s=document.querySelector("#switch_".concat(a.id));return this._weatherSpecializedLayerInstance?(this._map.setLayoutProperty("".concat(e),"visibility",t?"visible":"none"),t?null==s||s.setAttribute("checked","true"):null==s||s.removeAttribute("checked")):(this._weatherSpecializedLayerInstance=new c(this._map,this,{layerId:"Weather",isVisible:t,layerName:e}),this._map.on("weatherlayersloaded",(function(){t?null==s||s.setAttribute("checked","true"):null==s||s.removeAttribute("checked")})),void 0!==this._map&&void 0!==this._map.style&&this._map.style._loaded?this._weatherSpecializedLayerInstance.addTo(this._map):this._map.once("style.load",(function(){i._weatherSpecializedLayerInstance.addTo(i._map)}))),this._weatherSpecializedLayerInstance.isVisible()}console.warn("This control must be added to a map before content layer visibility can be set.")},e}()}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc