UNPKG

highcharts

Version:
13 lines 15.5 kB
/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/tiledwebmap * @requires highcharts * * (c) 2009-2026 * * A commercial license may be required depending on use, * see www.highcharts.com/license */import*as e from"../highcharts.js";let t={};t.n=e=>{let o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},t.d=(e,o)=>{if(Array.isArray(o))for(var r=0;r<o.length;){var i=o[r++],a=o[r++];t.o(e,i)?0===a&&r++:0===a?Object.defineProperty(e,i,{enumerable:!0,value:o[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:a})}else for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let o=e.default;var r=t.n(o);let i={Esri:class{constructor(){this.defaultCredits="Tiles &copy; Esri &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012",this.initialProjectionName="WebMercator",this.themes={WorldStreetMap:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20},DeLorme:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer/tile/{z}/{y}/{x}",minZoom:1,maxZoom:11,credits:"Tiles &copy; Esri &mdash; Copyright: &copy;2012 DeLorme"},WorldTopoMap:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20,credits:"Tiles &copy; Esri &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community"},WorldImagery:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20,credits:"Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"},WorldTerrain:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:13,credits:"Tiles &copy; Esri &mdash; Source: USGS, Esri, TANA, DeLorme, and NPS"},WorldShadedRelief:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:13,credits:"Tiles &copy; Esri &mdash; Source: Esri"},WorldPhysical:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:8,credits:"Tiles &copy; Esri &mdash; Source: US National Park Service"},NatGeoWorldMap:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:16,credits:"Tiles &copy; Esri &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC"},WorldGrayCanvas:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:16,credits:"Tiles &copy; Esri &mdash; Esri, DeLorme, NAVTEQ"},WorldDarkGrayCanvas:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:16,credits:"Tiles &copy; Esri &mdash; Esri, DeLorme, NAVTEQ"}}}},LimaLabs:class{constructor(){this.defaultCredits='Map data &copy;2023 <a href="https://maps.lima-labs.com/">LimaLabs</a>',this.initialProjectionName="WebMercator",this.requiresApiKey=!0,this.themes={Standard:{url:"https://cdn.lima-labs.com/{zoom}/{x}/{y}.png?api={apikey}",minZoom:0,maxZoom:20}}}},OpenStreetMap:class{constructor(){this.defaultCredits='Map data &copy2023 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',this.initialProjectionName="WebMercator",this.subdomains=["a","b","c"],this.themes={Standard:{url:"https://tile.openstreetmap.org/{zoom}/{x}/{y}.png",minZoom:0,maxZoom:19},Hot:{url:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",minZoom:0,maxZoom:19},OpenTopoMap:{url:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",minZoom:0,maxZoom:17,credits:`Map data: &copy; <a href="https://www.openstreetmap.org/copyright"> OpenStreetMap</a> contributors, <a href="https://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)`}}}},Stamen:class{constructor(){this.defaultCredits='&copy; Map tiles by <a href="https://stamen.com">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://www.openstreetmap.org/copyright">ODbL</a>',this.initialProjectionName="WebMercator",this.subdomains=["a","b","c","d"],this.themes={Toner:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png",minZoom:0,maxZoom:20},TonerBackground:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/toner-background/{z}/{x}/{y}.png",minZoom:0,maxZoom:20},TonerLite:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png",minZoom:0,maxZoom:20},Terrain:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png",minZoom:0,maxZoom:18},TerrainBackground:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png",minZoom:0,maxZoom:18},Watercolor:{url:"https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png",minZoom:1,maxZoom:16,credits:'&copy Map tiles by <a href="https://stamen.com">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>'}}}},Thunderforest:class{constructor(){this.defaultCredits='Maps &copy <a href="https://www.thunderforest.com">Thunderforest</a>, Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>',this.initialProjectionName="WebMercator",this.requiresApiKey=!0,this.subdomains=["a","b","c"],this.themes={OpenCycleMap:{url:"https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},Transport:{url:"https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},TransportDark:{url:"https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},SpinalMap:{url:"https://{s}.tile.thunderforest.com/spinal-map/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},Landscape:{url:"https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},Outdoors:{url:"https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},Pioneer:{url:"https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},MobileAtlas:{url:"https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22},Neighbourhood:{url:"https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png?apikey={apikey}",minZoom:0,maxZoom:22}}}},USGS:class{constructor(){this.defaultCredits='Tiles courtesy of the <a href="https://usgs.gov/">U.S. GeologicalSurvey</a>',this.initialProjectionName="WebMercator",this.themes={USTopo:{url:"https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20},USImagery:{url:"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20},USImageryTopo:{url:"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/{z}/{y}/{x}",minZoom:0,maxZoom:20}}}}},a=e.default.Fx;var s=t.n(a);let n=e.default.SeriesRegistry;var l=t.n(n);let{composed:p}=r(),{map:m}=l().seriesTypes;function c(e){let{geoBounds:t,chart:r}=e,a=(r.options.series||[]).filter(e=>"tiledwebmap"===e.type)[0];if(a&&a.provider&&a.provider.type&&!a.provider.url){let e=i[a.provider.type];if((0,o.defined)(e)){let{initialProjectionName:o}=new e;if(t){let{x1:e,y1:r,x2:i,y2:a}=t;this.recommendedMapView={projection:{name:o,parallels:[r,a],rotation:[-(e+i)/2]}}}else this.recommendedMapView={projection:{name:o},minZoom:0};return!1}(0,o.error)("Highcharts warning: Tiles Provider not defined in the Provider Registry.",!1)}return!0}class h extends m{constructor(){super(...arguments),this.redrawTiles=!1,this.isAnimating=!1}static compose(e){(0,o.pushUnique)(p,"TiledWebMapSeries")&&(0,o.addEvent)(e,"onRecommendMapView",c)}lonLatToTile(e,t){let{lon:o,lat:r}=e;return{x:Math.floor((o+180)/360*Math.pow(2,t)),y:Math.floor((1-Math.log(Math.tan(r*Math.PI/180)+1/Math.cos(r*Math.PI/180))/Math.PI)/2*Math.pow(2,t))}}tileToLonLat(e,t,o){let r=e/Math.pow(2,o)*360-180,i=Math.PI-2*Math.PI*t/Math.pow(2,o);return{lon:r,lat:180/Math.PI*Math.atan(.5*(Math.exp(i)-Math.exp(-i)))}}drawPoints(){let e=this.chart,t=e.mapView;if(!t)return;let r=this.tiles=this.tiles||{},a=this.transformGroups=this.transformGroups||[],n=this,l=this.options.provider,{zoom:p}=t,m=(0,o.pick)(t.projection.options.rotation&&t.projection.options.rotation[0],0),c=200*!e.renderer.forExport,h=e=>{for(let o of Object.keys(r))parseFloat(o)===(t.zoom<0?0:Math.floor(t.zoom))||n.minZoom&&(t.zoom<0?0:Math.floor(t.zoom))<n.minZoom&&parseFloat(o)===n.minZoom||n.maxZoom&&(t.zoom<0?0:Math.floor(t.zoom))>n.maxZoom&&parseFloat(o)===n.maxZoom?Object.keys(r[o].tiles).forEach((t,i)=>{r[o].tiles[t].animate({opacity:1},{duration:e},()=>{i===Object.keys(r[o].tiles).length-1&&(r[o].isActive=!0)})}):Object.keys(r[o].tiles).forEach((t,i)=>{r[o].tiles[t].animate({opacity:0},{duration:e,defer:e/2},()=>{r[o].tiles[t].destroy(),delete r[o].tiles[t],i===Object.keys(r[o].tiles).length-1&&(r[o].isActive=!1,r[o].loaded=!1)})})},d=p<0?0:Math.floor(p),y=Math.pow(2,d),u=.638436911716859*Math.pow(2,p)/(.638436911716859*Math.pow(2,d)),f=256*u;if(l&&(l.type||l.url)){if(l.type&&!l.url){let r=i[l.type];if(!(0,o.defined)(r))return void(0,o.error)("Highcharts warning: Tiles Provider '"+l.type+"' not defined in the ProviderRegistry.",!1);let a=new r,s=a.initialProjectionName,n,p="";if(l.theme&&(0,o.defined)(a.themes[l.theme]))n=a.themes[l.theme];else{let e=Object.keys(a.themes)[0];n=a.themes[e],(0,o.error)("Highcharts warning: The Tiles Provider's Theme '"+l.theme+"' is not defined in the Provider definition - falling back to '"+e+"'.",!1)}l.subdomain&&a.subdomains&&-1!==a.subdomains.indexOf(l.subdomain)?p=l.subdomain:(0,o.defined)(a.subdomains)&&-1!==n.url.indexOf("{s}")&&(p=(0,o.pick)(a.subdomains&&a.subdomains[0],""),(0,o.error)("Highcharts warning: The Tiles Provider's Subdomain '"+l.subdomain+"' is not defined in the Provider definition - falling back to '"+p+"'.",!1)),a.requiresApiKey&&(l.apiKey?n.url=n.url.replace("{apikey}",l.apiKey):((0,o.error)("Highcharts warning: The Tiles Provider requires API Key to use tiles, use provider.apiKey to provide a token.",!1),n.url=n.url.replace("?apikey={apikey}",""))),l.url=n.url.replace("{s}",p),this.minZoom=n.minZoom,this.maxZoom=n.maxZoom;let m=(0,o.pick)(e.userOptions.credits&&e.userOptions.credits.text,"Highcharts.com "+(0,o.pick)(n.credits,a.defaultCredits));e.credits?e.credits.update({text:m}):e.addCredits({text:m,style:(0,o.pick)(e.options.credits?.style,{})}),t.projection.options.name!==s&&(0,o.error)("Highcharts warning: The set projection is different than supported by Tiles Provider.",!1)}else t.projection.options.name||(0,o.error)("Highcharts warning: The set projection is different than supported by Tiles Provider.",!1);if((0,o.defined)(this.minZoom)&&d<this.minZoom?(y=Math.pow(2,d=this.minZoom),f=256*(u=.638436911716859*Math.pow(2,p)/(.638436911716859*Math.pow(2,d)))):(0,o.defined)(this.maxZoom)&&d>this.maxZoom&&(y=Math.pow(2,d=this.maxZoom),f=256*(u=.638436911716859*Math.pow(2,p)/(.638436911716859*Math.pow(2,d)))),t.projection&&t.projection.def){t.projection.hasCoordinates=!0,a[d]||(a[d]=e.renderer.g().add(this.group));let o=(o,i,s,p,m)=>{let d=o%y,u=i%y,g=d<0?d+y:d,x=u<0?u+y:u;if(!r[`${s}`].tiles[`${o},${i}`]&&l.url){let d,y=(d=l.url,d.replace("{x}",g.toString()).replace("{y}",x.toString()).replace("{zoom}",s.toString()).replace("{z}",s.toString()));r[s].loaded=!1,r[`${s}`].tiles[`${o},${i}`]=e.renderer.image(y,o*f-p,i*f-m,f,f).attr({zIndex:2,opacity:0}).on("load",function(){l.onload&&l.onload.apply(this),(s===(t.zoom<0?0:Math.floor(t.zoom))||s===n.minZoom)&&(r[`${s}`].actualTilesCount++,r[`${s}`].howManyTiles===r[`${s}`].actualTilesCount&&(r[s].loaded=!0,n.isAnimating?n.redrawTiles=!0:(n.redrawTiles=!1,h(c)),r[`${s}`].actualTilesCount=0))}).add(a[s]),r[`${s}`].tiles[`${o},${i}`].posX=o,r[`${s}`].tiles[`${o},${i}`].posY=i,r[`${s}`].tiles[`${o},${i}`].originalURL=y}},i=t.pixelsToProjectedUnits({x:0,y:0}),s=t.projection.def.inverse([i.x,i.y]),p={lon:s[0]-m,lat:s[1]},u=t.pixelsToProjectedUnits({x:e.plotWidth,y:e.plotHeight}),g=t.projection.def.inverse([u.x,u.y]),x={lon:g[0]-m,lat:g[1]};(p.lat>t.projection.maxLatitude||x.lat<-1*t.projection.maxLatitude)&&(p.lat=t.projection.maxLatitude,x.lat=-1*t.projection.maxLatitude);let M=this.lonLatToTile(p,d),T=this.lonLatToTile(x,d),v=this.tileToLonLat(M.x,M.y,d),S=t.projection.def.forward([v.lon+m,v.lat]),Z=t.projectedUnitsToPixels({x:S[0],y:S[1]}),b=M.x*f-Z.x,w=M.y*f-Z.y;r[`${d}`]||(r[`${d}`]={tiles:{},isActive:!1,howManyTiles:0,actualTilesCount:0,loaded:!1}),r[`${d}`].howManyTiles=(T.x-M.x+1)*(T.y-M.y+1),r[`${d}`].actualTilesCount=0;for(let e=M.x;e<=T.x;e++)for(let t=M.y;t<=T.y;t++)o(e,t,d,b,w)}for(let i of Object.keys(r))for(let a of Object.keys(r[i].tiles))if(t.projection&&t.projection.def){let l=r[i].tiles[a];s().timers.length>0&&(0,o.stop)(l,"animator");let y=256*(.638436911716859*Math.pow(2,p)/(.638436911716859*Math.pow(2,parseFloat(i)))),u=r[i].tiles[Object.keys(r[i].tiles)[0]],{posX:f,posY:g}=l;if((0,o.defined)(f)&&(0,o.defined)(g)&&(0,o.defined)(u.posX)&&(0,o.defined)(u.posY)){let o=this.tileToLonLat(u.posX,u.posY,parseFloat(i)),a=t.projection.def.forward([o.lon+m,o.lat]),s=t.projectedUnitsToPixels({x:a[0],y:a[1]}),p=u.posX*y-s.x,x=u.posY*y-s.y;if(e.renderer.globalAnimation&&e.hasRendered){let e=Number(l.attr("x")),t=Number(l.attr("y")),o=Number(l.attr("width")),r=Number(l.attr("height")),i=(i,a)=>{l.attr({x:e+(f*y-p-e)*a.pos,y:t+(g*y-x-t)*a.pos,width:o+(Math.ceil(y)+1-o)*a.pos,height:r+(Math.ceil(y)+1-r)*a.pos})};n.isAnimating=!0,l.attr({animator:0}).animate({animator:1},{step:i},function(){n.isAnimating=!1,n.redrawTiles&&(n.redrawTiles=!1,h(c))})}else(n.redrawTiles||parseFloat(i)!==d||(r[i].isActive||parseFloat(i)===d)&&Object.keys(r[i].tiles).map(e=>r[i].tiles[e]).some(e=>0===e.opacity))&&(n.redrawTiles=!1,h(c)),l.attr({x:f*y-p,y:g*y-x,width:Math.ceil(y)+1,height:Math.ceil(y)+1})}}}else(0,o.error)("Highcharts warning: Tiles Provider not defined in the Provider Registry.",!1)}update(e){let{transformGroups:t}=this,r=this.chart,a=r.mapView,{provider:s}=e;if(t&&(t.forEach(e=>{0!==Object.keys(e).length&&e.destroy()}),this.transformGroups=[]),a&&!(0,o.defined)(r.userOptions.mapView?.projection)&&s?.type){let e=i[s.type];e&&a.update({projection:{name:new e().initialProjectionName}},!1)}super.update.apply(this,arguments)}}h.defaultOptions=(0,o.merge)(m.defaultOptions,{states:{inactive:{enabled:!1}}}),l().registerSeriesType("tiledwebmap",h);let d=r();d.TilesProviderRegistry=d.TilesProviderRegistry||i,h.compose(d.MapView);let y=r();export{y as default};