@arenarium/maps 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const t=()=>'<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />',e=()=>`<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${t()}<span>&nbsp;@arenarium/maps</span></a>`;exports.getAttributionHtml=e;
@@ -0,0 +1,4 @@
1
+ const t = () => '<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />', a = () => `<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${t()}<span>&nbsp;@arenarium/maps</span></a>`;
2
+ export {
3
+ a as g
4
+ };
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var p=(s,e,t)=>e in s?i(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var l=(s,e,t)=>p(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class m{constructor(e,t,a,n){l(this,"MapClass");l(this,"MapMarkerClass");l(this,"map");l(this,"options");this.MapClass=e,this.MapMarkerClass=t,this.options=n,this.map=new this.MapClass(a,{...n})}getParameters(){return{mapSize:256,zoomMin:this.options.minZoom??0,zoomMax:this.options.maxZoom??24,zoomScale:10}}getMap(){return this.map}getContainer(){return this.map.getDiv()}getZoom(){return this.map.getZoom()??NaN}getBounds(){const e=this.map.getBounds();if(e==null)return{sw:{lat:NaN,lng:NaN},ne:{lat:NaN,lng:NaN}};const t=e.getSouthWest(),a=e.getNorthEast();return{sw:{lat:t.lat(),lng:t.lng()},ne:{lat:a.lat(),lng:a.lng()}}}panBy(e,t){this.map.panBy(e,t)}createMarker(e,t,a,n){const o=new this.MapMarkerClass({position:{lat:t,lng:a},content:e,zIndex:n});return{instance:o,inserted:()=>o.map!=null&&o.map==this.map,insert:()=>o.map=this.map,remove:()=>o.map=void 0,update:r=>o.zIndex=r}}}const g=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100},{lightness:-10}]},{featureType:"landscape",stylers:[{lightness:30}]},{featureType:"road",elementType:"geometry",stylers:[{saturation:-100}]}],y=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100}]},{elementType:"geometry",stylers:[{lightness:-45}]},{elementType:"labels.text.fill",stylers:[{lightness:-100}]},{elementType:"labels.text.stroke",stylers:[{lightness:-15}]},{featureType:"water",elementType:"geometry",stylers:[{lightness:-50}]}];exports.GoogleMapDarkStyle=y;exports.GoogleMapLightStyle=g;exports.GoogleMapsProvider=m;
1
+ "use strict";var l=Object.defineProperty;var m=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var r=(a,t,e)=>m(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./attribution-3vg4I3xA.cjs");class p{constructor(t,e,s,i){r(this,"MapClass");r(this,"MapMarkerClass");r(this,"map");r(this,"options");r(this,"attributionObserver");r(this,"attributionElement");this.MapClass=t,this.MapMarkerClass=e,this.options=i,this.map=new this.MapClass(s,{...i}),(i.attribution||i.attribution==null)&&(this.map.addListener("idle",()=>{this.attributionObserver||(this.attributionObserver=new MutationObserver((n,o)=>{this.insertAttributionElement(),this.attributionElement!=null&&(this.updateAttributionElement(),o.disconnect())}),this.attributionObserver.observe(s,{childList:!0,subtree:!0}))}),this.map.addListener("bounds_changed",()=>{this.updateAttributionElement()}))}insertAttributionElement(){var n,o;const t=this.map.getDiv();if(t==null)return;const e=t.getElementsByClassName("gmnoprint")[0];if(e==null||e.parentElement==null)return;const s=e.cloneNode(!0),i=(o=(n=s.childNodes.item(0))==null?void 0:n.childNodes.item(1))==null?void 0:o.childNodes.item(0);i!=null&&(i.title="",i.innerHTML=u.getAttributionHtml(),e.parentElement.insertBefore(s,e),this.attributionElement=i)}updateAttributionElement(){var s,i;const t=this.map.getDiv();if(t==null)return;const e=(i=(s=this.attributionElement)==null?void 0:s.childNodes.item(0))==null?void 0:i.childNodes.item(1);e!=null&&(e.style.display=t.clientWidth>500?"initial":"none")}getParameters(){return{mapSize:256,zoomMin:this.options.minZoom??0,zoomMax:this.options.maxZoom??24,zoomScale:10}}getMap(){return this.map}getContainer(){return this.map.getDiv()}getZoom(){return this.map.getZoom()??NaN}getBounds(){const t=this.map.getBounds();if(t==null)return{sw:{lat:NaN,lng:NaN},ne:{lat:NaN,lng:NaN}};const e=t.getSouthWest(),s=t.getNorthEast();return{sw:{lat:e.lat(),lng:e.lng()},ne:{lat:s.lat(),lng:s.lng()}}}panBy(t,e){this.map.panBy(t,e)}createMarker(t,e,s,i){const n=new this.MapMarkerClass({position:{lat:e,lng:s},content:t,zIndex:i});return{instance:n,inserted:()=>n.map!=null&&n.map==this.map,insert:()=>n.map=this.map,remove:()=>n.map=void 0,update:o=>n.zIndex=o}}}const d=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100},{lightness:-10}]},{featureType:"landscape",stylers:[{lightness:30}]},{featureType:"road",elementType:"geometry",stylers:[{saturation:-100}]}],h=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100}]},{elementType:"geometry",stylers:[{lightness:-45}]},{elementType:"labels.text.fill",stylers:[{lightness:-100}]},{elementType:"labels.text.stroke",stylers:[{lightness:-15}]},{featureType:"water",elementType:"geometry",stylers:[{lightness:-50}]}];exports.GoogleMapDarkStyle=h;exports.GoogleMapLightStyle=d;exports.GoogleMapsProvider=p;
package/dist/google.d.ts CHANGED
@@ -64,12 +64,20 @@ declare interface GoogleMapsMarkerClass {
64
64
  new (options: google.maps.marker.AdvancedMarkerElementOptions): google.maps.marker.AdvancedMarkerElement;
65
65
  }
66
66
 
67
+ declare interface GoogleMapsOptions extends google.maps.MapOptions {
68
+ attribution?: boolean;
69
+ }
70
+
67
71
  export declare class GoogleMapsProvider implements MapProvider {
68
72
  private MapClass;
69
73
  private MapMarkerClass;
70
74
  private map;
71
75
  private options;
72
- constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: google.maps.MapOptions);
76
+ private attributionObserver;
77
+ private attributionElement;
78
+ constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: GoogleMapsOptions);
79
+ private insertAttributionElement;
80
+ private updateAttributionElement;
73
81
  getParameters(): MapProviderParameters;
74
82
  getMap(): google.maps.Map;
75
83
  getContainer(): HTMLElement;
package/dist/google.es.js CHANGED
@@ -1,15 +1,40 @@
1
- var i = Object.defineProperty;
2
- var p = (s, e, t) => e in s ? i(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var l = (s, e, t) => p(s, typeof e != "symbol" ? e + "" : e, t);
4
- class g {
5
- constructor(e, t, a, o) {
6
- l(this, "MapClass");
7
- l(this, "MapMarkerClass");
8
- l(this, "map");
9
- l(this, "options");
10
- this.MapClass = e, this.MapMarkerClass = t, this.options = o, this.map = new this.MapClass(a, {
11
- ...o
12
- });
1
+ var l = Object.defineProperty;
2
+ var m = (a, t, e) => t in a ? l(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var r = (a, t, e) => m(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { g as p } from "./attribution-BYiDRQF4.js";
5
+ class h {
6
+ constructor(t, e, s, i) {
7
+ r(this, "MapClass");
8
+ r(this, "MapMarkerClass");
9
+ r(this, "map");
10
+ r(this, "options");
11
+ r(this, "attributionObserver");
12
+ r(this, "attributionElement");
13
+ this.MapClass = t, this.MapMarkerClass = e, this.options = i, this.map = new this.MapClass(s, {
14
+ ...i
15
+ }), (i.attribution || i.attribution == null) && (this.map.addListener("idle", () => {
16
+ this.attributionObserver || (this.attributionObserver = new MutationObserver((n, o) => {
17
+ this.insertAttributionElement(), this.attributionElement != null && (this.updateAttributionElement(), o.disconnect());
18
+ }), this.attributionObserver.observe(s, { childList: !0, subtree: !0 }));
19
+ }), this.map.addListener("bounds_changed", () => {
20
+ this.updateAttributionElement();
21
+ }));
22
+ }
23
+ insertAttributionElement() {
24
+ var n, o;
25
+ const t = this.map.getDiv();
26
+ if (t == null) return;
27
+ const e = t.getElementsByClassName("gmnoprint")[0];
28
+ if (e == null || e.parentElement == null) return;
29
+ const s = e.cloneNode(!0), i = (o = (n = s.childNodes.item(0)) == null ? void 0 : n.childNodes.item(1)) == null ? void 0 : o.childNodes.item(0);
30
+ i != null && (i.title = "", i.innerHTML = p(), e.parentElement.insertBefore(s, e), this.attributionElement = i);
31
+ }
32
+ updateAttributionElement() {
33
+ var s, i;
34
+ const t = this.map.getDiv();
35
+ if (t == null) return;
36
+ const e = (i = (s = this.attributionElement) == null ? void 0 : s.childNodes.item(0)) == null ? void 0 : i.childNodes.item(1);
37
+ e != null && (e.style.display = t.clientWidth > 500 ? "initial" : "none");
13
38
  }
14
39
  getParameters() {
15
40
  return {
@@ -29,26 +54,26 @@ class g {
29
54
  return this.map.getZoom() ?? NaN;
30
55
  }
31
56
  getBounds() {
32
- const e = this.map.getBounds();
33
- if (e == null) return { sw: { lat: NaN, lng: NaN }, ne: { lat: NaN, lng: NaN } };
34
- const t = e.getSouthWest(), a = e.getNorthEast();
35
- return { sw: { lat: t.lat(), lng: t.lng() }, ne: { lat: a.lat(), lng: a.lng() } };
57
+ const t = this.map.getBounds();
58
+ if (t == null) return { sw: { lat: NaN, lng: NaN }, ne: { lat: NaN, lng: NaN } };
59
+ const e = t.getSouthWest(), s = t.getNorthEast();
60
+ return { sw: { lat: e.lat(), lng: e.lng() }, ne: { lat: s.lat(), lng: s.lng() } };
36
61
  }
37
- panBy(e, t) {
38
- this.map.panBy(e, t);
62
+ panBy(t, e) {
63
+ this.map.panBy(t, e);
39
64
  }
40
- createMarker(e, t, a, o) {
41
- const n = new this.MapMarkerClass({ position: { lat: t, lng: a }, content: e, zIndex: o });
65
+ createMarker(t, e, s, i) {
66
+ const n = new this.MapMarkerClass({ position: { lat: e, lng: s }, content: t, zIndex: i });
42
67
  return {
43
68
  instance: n,
44
69
  inserted: () => n.map != null && n.map == this.map,
45
70
  insert: () => n.map = this.map,
46
71
  remove: () => n.map = void 0,
47
- update: (r) => n.zIndex = r
72
+ update: (o) => n.zIndex = o
48
73
  };
49
74
  }
50
75
  }
51
- const y = [
76
+ const g = [
52
77
  {
53
78
  elementType: "labels.icon",
54
79
  stylers: [
@@ -84,7 +109,7 @@ const y = [
84
109
  }
85
110
  ]
86
111
  }
87
- ], h = [
112
+ ], b = [
88
113
  {
89
114
  elementType: "labels.icon",
90
115
  stylers: [
@@ -135,7 +160,7 @@ const y = [
135
160
  }
136
161
  ];
137
162
  export {
138
- h as GoogleMapDarkStyle,
139
- y as GoogleMapLightStyle,
140
- g as GoogleMapsProvider
163
+ b as GoogleMapDarkStyle,
164
+ g as GoogleMapLightStyle,
165
+ h as GoogleMapsProvider
141
166
  };
package/dist/index.d.ts CHANGED
@@ -549,12 +549,19 @@ export interface GoogleMapsClass {
549
549
  export interface GoogleMapsMarkerClass {
550
550
  new (options: google.maps.marker.AdvancedMarkerElementOptions): google.maps.marker.AdvancedMarkerElement;
551
551
  }
552
+ export interface GoogleMapsOptions extends google.maps.MapOptions {
553
+ attribution?: boolean;
554
+ }
552
555
  export declare class GoogleMapsProvider implements MapProvider {
553
556
  private MapClass;
554
557
  private MapMarkerClass;
555
558
  private map;
556
559
  private options;
557
- constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: google.maps.MapOptions);
560
+ private attributionObserver;
561
+ private attributionElement;
562
+ constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: GoogleMapsOptions);
563
+ private insertAttributionElement;
564
+ private updateAttributionElement;
558
565
  getParameters(): MapProviderParameters;
559
566
  getMap(): google.maps.Map;
560
567
  getContainer(): HTMLElement;