@arenarium/maps-integration-google 1.0.1 → 1.0.3
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.
- package/LICENSE.txt +1 -1
- package/dist/main.d.ts +36 -93
- package/dist/main.js +1 -0
- package/package.json +43 -44
- package/dist/main.cjs.js +0 -1
- package/dist/main.es.js +0 -243
- package/src/lib/provider.ts +0 -144
- package/src/lib/styles.ts +0 -88
- package/src/main.ts +0 -3
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -23
package/LICENSE.txt
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -1,93 +1,36 @@
|
|
|
1
|
-
import { MapBounds } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
featureType?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
stylers: ({
|
|
40
|
-
saturation: number;
|
|
41
|
-
lightness?: undefined;
|
|
42
|
-
} | {
|
|
43
|
-
lightness: number;
|
|
44
|
-
saturation?: undefined;
|
|
45
|
-
})[];
|
|
46
|
-
elementType?: undefined;
|
|
47
|
-
featureType?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
featureType: string;
|
|
50
|
-
stylers: {
|
|
51
|
-
lightness: number;
|
|
52
|
-
}[];
|
|
53
|
-
elementType?: undefined;
|
|
54
|
-
} | {
|
|
55
|
-
featureType: string;
|
|
56
|
-
elementType: string;
|
|
57
|
-
stylers: {
|
|
58
|
-
saturation: number;
|
|
59
|
-
}[];
|
|
60
|
-
})[];
|
|
61
|
-
|
|
62
|
-
declare interface GoogleMapsClass {
|
|
63
|
-
new (container: HTMLElement, options: google.maps.MapOptions): google.maps.Map;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
declare interface GoogleMapsMarkerClass {
|
|
67
|
-
new (options: google.maps.marker.AdvancedMarkerElementOptions): google.maps.marker.AdvancedMarkerElement;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declare interface GoogleMapsOptions extends google.maps.MapOptions {
|
|
71
|
-
attribution?: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export declare class GoogleMapsProvider implements MapProvider {
|
|
75
|
-
private MapClass;
|
|
76
|
-
private MapMarkerClass;
|
|
77
|
-
private map;
|
|
78
|
-
private options;
|
|
79
|
-
private attributionObserver;
|
|
80
|
-
private attributionElement;
|
|
81
|
-
constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: GoogleMapsOptions);
|
|
82
|
-
private insertAttributionElement;
|
|
83
|
-
private updateAttributionElement;
|
|
84
|
-
getParameters(): MapProviderParameters;
|
|
85
|
-
getMap(): google.maps.Map;
|
|
86
|
-
getContainer(): HTMLElement;
|
|
87
|
-
getZoom(): number;
|
|
88
|
-
getBounds(): MapBounds;
|
|
89
|
-
panBy(x: number, y: number): undefined;
|
|
90
|
-
createMarker(element: HTMLElement, lat: number, lng: number, zIndex: number): MapProviderMarker;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { }
|
|
1
|
+
import { MapProvider, MapProviderParameters, MapProviderMarker, MapProviderEvent, MapBounds, MapViewport, MapCoordinates } from "@arenarium/maps-core/schemas";
|
|
2
|
+
interface GoogleMapsClass {
|
|
3
|
+
new (container: HTMLElement, options: google.maps.MapOptions): google.maps.Map;
|
|
4
|
+
}
|
|
5
|
+
interface GoogleMapsMarkerClass {
|
|
6
|
+
new (options: google.maps.marker.AdvancedMarkerElementOptions): google.maps.marker.AdvancedMarkerElement;
|
|
7
|
+
}
|
|
8
|
+
interface GoogleMapsOptions extends google.maps.MapOptions {
|
|
9
|
+
attribution?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare class GoogleMapsProvider implements MapProvider {
|
|
12
|
+
private MapClass;
|
|
13
|
+
private MapMarkerClass;
|
|
14
|
+
private map;
|
|
15
|
+
private options;
|
|
16
|
+
private listeners;
|
|
17
|
+
private attributionObserver;
|
|
18
|
+
private attributionElement;
|
|
19
|
+
constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: GoogleMapsOptions);
|
|
20
|
+
private insertAttributionElement;
|
|
21
|
+
private updateAttributionElement;
|
|
22
|
+
getParameters(): MapProviderParameters;
|
|
23
|
+
getMap(): google.maps.Map;
|
|
24
|
+
getContainer(): HTMLElement;
|
|
25
|
+
getZoom(): number;
|
|
26
|
+
getCenter(): MapCoordinates;
|
|
27
|
+
getBounds(): MapBounds;
|
|
28
|
+
getViewport(): MapViewport;
|
|
29
|
+
panBy(x: number, y: number): undefined;
|
|
30
|
+
createMarker(element: HTMLElement, lat: number, lng: number, zIndex: number): MapProviderMarker;
|
|
31
|
+
subscribe(event: MapProviderEvent, callback: () => void): void;
|
|
32
|
+
unsubscribe(event: MapProviderEvent, callback: () => void): void;
|
|
33
|
+
}
|
|
34
|
+
declare const GoogleMapLightStyle: google.maps.MapTypeStyle[];
|
|
35
|
+
declare const GoogleMapDarkStyle: google.maps.MapTypeStyle[];
|
|
36
|
+
export { GoogleMapsProvider, GoogleMapLightStyle, GoogleMapDarkStyle };
|
package/dist/main.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAttributionHtml as S}from"@arenarium/maps-core/attribution";class M{MapClass;MapMarkerClass;map;options;listeners=new Set;attributionObserver;attributionElement;constructor(s,y,f,g){if(this.MapClass=s,this.MapMarkerClass=y,this.options=g,this.map=new this.MapClass(f,{...g}),g.attribution||g.attribution==null)this.map.addListener("idle",()=>{if(this.attributionObserver)return;this.attributionObserver=new MutationObserver((T,G)=>{if(this.insertAttributionElement(),this.attributionElement==null)return;this.updateAttributionElement(),G.disconnect()}),this.attributionObserver.observe(f,{childList:!0,subtree:!0})}),this.map.addListener("bounds_changed",()=>{this.updateAttributionElement()})}insertAttributionElement(){let s=this.map.getDiv();if(s==null)return;let y=s.getElementsByClassName("gmnoprint")[0];if(y==null)return;if(y.parentElement==null)return;let f=y.cloneNode(!0),g=f.childNodes.item(0)?.childNodes.item(1)?.childNodes.item(0);if(g==null)return;g.title="",g.innerHTML=S(),y.parentElement.insertBefore(f,y),this.attributionElement=g}updateAttributionElement(){let s=this.map.getDiv();if(s==null)return;let y=this.attributionElement?.childNodes.item(0);if(y){y.style.height="14px",y.style.display="inline-flex",y.style.alignItems="center",y.style.gap="1px";let f=y.childNodes.item(0);if(f)f.style.height="12px",f.style.width="auto";let g=y.childNodes.item(1);if(g)g.style.display=s.clientWidth>500?"initial":"none",g.style.color=this.options.colorScheme==google.maps.ColorScheme.DARK?"#fff":"#000"}}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}getCenter(){let s=this.map.getCenter();if(s==null)return{lat:NaN,lng:NaN};return{lat:s.lat(),lng:s.lng()}}getBounds(){let s=this.map.getBounds();if(s==null)return{sw:{lat:NaN,lng:NaN},ne:{lat:NaN,lng:NaN}};let y=s.getSouthWest(),f=s.getNorthEast();return{sw:{lat:y.lat(),lng:y.lng()},ne:{lat:f.lat(),lng:f.lng()}}}getViewport(){return{bounds:this.getBounds(),center:this.getCenter(),zoom:this.getZoom()}}panBy(s,y){this.map.panBy(s,y)}createMarker(s,y,f,g){let T=new this.MapMarkerClass({position:{lat:y,lng:f},content:s,zIndex:g});return{inserted:()=>T.map!=null&&T.map==this.map,insert:()=>T.map=this.map,remove:()=>T.map=void 0,update:(G)=>T.zIndex=G}}subscribe(s,y){let f=google.maps.event.addListener(this.map,s,y);this.listeners.add({id:f,event:s,callback:y})}unsubscribe(s,y){let f=this.listeners.values().find((g)=>g.event==s&&g.callback==y);if(f==null)return;google.maps.event.removeListener(f.id)}}var D=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100},{lightness:-10}]},{featureType:"landscape",stylers:[{lightness:30}]},{featureType:"road",elementType:"geometry",stylers:[{saturation:-100}]}],P=[{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}]}];export{M as GoogleMapsProvider,D as GoogleMapLightStyle,P as GoogleMapDarkStyle};
|
package/package.json
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
2
|
+
"name": "@arenarium/maps-integration-google",
|
|
3
|
+
"description": "Integration with Google Maps for @arenarium/maps.",
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/main.js",
|
|
10
|
+
"types": "./dist/main.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/main.d.ts",
|
|
15
|
+
"default": "./dist/main.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "arenarium",
|
|
22
|
+
"homepage": "https://arenarium.dev",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"arenarium",
|
|
25
|
+
"maps",
|
|
26
|
+
"google",
|
|
27
|
+
"google maps"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"bunup": "^0.16.10"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@googlemaps/js-api-loader": "^2.0.2",
|
|
34
|
+
"@types/google.maps": "^3.58.1"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@arenarium/maps-core": "1.0.2"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"lib_google_build": "bunup",
|
|
41
|
+
"lib_google_patch": "bun pm version patch --no-git-tag-version",
|
|
42
|
+
"lib_google_publish": "bun publish --access public"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/main.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(d);var u;(l=>{function i(e,s,t){const n=e/2,a=s/2,r=Math.sqrt(n*n+a*a),h=Math.atan(a/n)*(180/Math.PI),o=t*(Math.PI/180);return t<180?t<90?t<h?{x:0,y:r*Math.sin(o)-a}:{x:r*Math.cos(o)-n,y:0}:t<180-h?{x:r*Math.cos(o)-n,y:0}:{x:-e,y:r*Math.sin(o)-a}:t<270?t<180+h?{x:-e,y:r*Math.sin(o)-a}:{x:r*Math.cos(o)-n,y:-s}:t<360-h?{x:r*Math.cos(o)-n,y:-s}:{x:0,y:r*Math.sin(o)-a}}l.getOffsets=i})(u||(u={}));var p;(l=>{async function i(s,t){const n=await fetch(s,t);if(!n.ok)throw new Error(n.statusText);return n.json()}l.get=i;async function e(s,t,n){const a=await fetch(s,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n?.headers},...n});if(!a.ok)throw new Error(a.statusText);return a.json()}l.post=e})(p||(p={}));var m;(l=>{function i(r,h,o){return{x:s(h)*o,y:t(r)*o}}l.project=i;function e(r,h,o){return{lat:a(h/o),lng:n(r/o)}}l.unproject=e;function s(r){return(180+r)/360}function t(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function n(r){return r*360-180}function a(r){return 360/Math.PI*Math.atan(Math.exp((180-r*360)*Math.PI/180))-90}})(m||(m={}));var c;(l=>{l.COUNT=12,l.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],l.DEGREES_DEFAULT=270})(c||(c={}));const y=()=>'<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />',g=()=>`<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${y()}<span> @arenarium/maps</span></a>`;class M{constructor(i,e,s,t){this.MapClass=i,this.MapMarkerClass=e,this.options=t,this.map=new this.MapClass(s,{...t}),(t.attribution||t.attribution==null)&&(this.map.addListener("idle",()=>{this.attributionObserver||(this.attributionObserver=new MutationObserver((n,a)=>{this.insertAttributionElement(),this.attributionElement!=null&&(this.updateAttributionElement(),a.disconnect())}),this.attributionObserver.observe(s,{childList:!0,subtree:!0}))}),this.map.addListener("bounds_changed",()=>{this.updateAttributionElement()}))}insertAttributionElement(){const i=this.map.getDiv();if(i==null)return;const e=i.getElementsByClassName("gmnoprint")[0];if(e==null||e.parentElement==null)return;const s=e.cloneNode(!0),t=s.childNodes.item(0)?.childNodes.item(1)?.childNodes.item(0);t!=null&&(t.title="",t.innerHTML=g(),e.parentElement.insertBefore(s,e),this.attributionElement=t)}updateAttributionElement(){const i=this.map.getDiv();if(i==null)return;const e=this.attributionElement?.childNodes.item(0)?.childNodes.item(1);e!=null&&(e.style.display=i.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 i=this.map.getBounds();if(i==null)return{sw:{lat:NaN,lng:NaN},ne:{lat:NaN,lng:NaN}};const e=i.getSouthWest(),s=i.getNorthEast();return{sw:{lat:e.lat(),lng:e.lng()},ne:{lat:s.lat(),lng:s.lng()}}}panBy(i,e){this.map.panBy(i,e)}createMarker(i,e,s,t){const n=new this.MapMarkerClass({position:{lat:e,lng:s},content:i,zIndex:t});return{inserted:()=>n.map!=null&&n.map==this.map,insert:()=>n.map=this.map,remove:()=>n.map=void 0,update:a=>n.zIndex=a}}}const f=[{elementType:"labels.icon",stylers:[{visibility:"off"}]},{stylers:[{saturation:-100},{lightness:-10}]},{featureType:"landscape",stylers:[{lightness:30}]},{featureType:"road",elementType:"geometry",stylers:[{saturation:-100}]}],b=[{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=b;exports.GoogleMapLightStyle=f;exports.GoogleMapsProvider=M;
|
package/dist/main.es.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add("5");
|
|
2
|
-
var u;
|
|
3
|
-
((l) => {
|
|
4
|
-
function i(e, s, t) {
|
|
5
|
-
const n = e / 2, a = s / 2, r = Math.sqrt(n * n + a * a), h = Math.atan(a / n) * (180 / Math.PI), o = t * (Math.PI / 180);
|
|
6
|
-
return t < 180 ? t < 90 ? t < h ? {
|
|
7
|
-
x: 0,
|
|
8
|
-
y: r * Math.sin(o) - a
|
|
9
|
-
} : {
|
|
10
|
-
x: r * Math.cos(o) - n,
|
|
11
|
-
y: 0
|
|
12
|
-
} : t < 180 - h ? {
|
|
13
|
-
x: r * Math.cos(o) - n,
|
|
14
|
-
y: 0
|
|
15
|
-
} : {
|
|
16
|
-
x: -e,
|
|
17
|
-
y: r * Math.sin(o) - a
|
|
18
|
-
} : t < 270 ? t < 180 + h ? {
|
|
19
|
-
x: -e,
|
|
20
|
-
y: r * Math.sin(o) - a
|
|
21
|
-
} : {
|
|
22
|
-
x: r * Math.cos(o) - n,
|
|
23
|
-
y: -s
|
|
24
|
-
} : t < 360 - h ? {
|
|
25
|
-
x: r * Math.cos(o) - n,
|
|
26
|
-
y: -s
|
|
27
|
-
} : {
|
|
28
|
-
x: 0,
|
|
29
|
-
y: r * Math.sin(o) - a
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
l.getOffsets = i;
|
|
33
|
-
})(u || (u = {}));
|
|
34
|
-
var m;
|
|
35
|
-
((l) => {
|
|
36
|
-
async function i(s, t) {
|
|
37
|
-
const n = await fetch(s, t);
|
|
38
|
-
if (!n.ok) throw new Error(n.statusText);
|
|
39
|
-
return n.json();
|
|
40
|
-
}
|
|
41
|
-
l.get = i;
|
|
42
|
-
async function e(s, t, n) {
|
|
43
|
-
const a = await fetch(s, {
|
|
44
|
-
method: "POST",
|
|
45
|
-
body: JSON.stringify(t),
|
|
46
|
-
headers: {
|
|
47
|
-
"Content-Type": "application/json",
|
|
48
|
-
...n?.headers
|
|
49
|
-
},
|
|
50
|
-
...n
|
|
51
|
-
});
|
|
52
|
-
if (!a.ok) throw new Error(a.statusText);
|
|
53
|
-
return a.json();
|
|
54
|
-
}
|
|
55
|
-
l.post = e;
|
|
56
|
-
})(m || (m = {}));
|
|
57
|
-
var p;
|
|
58
|
-
((l) => {
|
|
59
|
-
function i(r, h, o) {
|
|
60
|
-
return {
|
|
61
|
-
x: s(h) * o,
|
|
62
|
-
y: t(r) * o
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
l.project = i;
|
|
66
|
-
function e(r, h, o) {
|
|
67
|
-
return {
|
|
68
|
-
lat: a(h / o),
|
|
69
|
-
lng: n(r / o)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
l.unproject = e;
|
|
73
|
-
function s(r) {
|
|
74
|
-
return (180 + r) / 360;
|
|
75
|
-
}
|
|
76
|
-
function t(r) {
|
|
77
|
-
return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + r * Math.PI / 360))) / 360;
|
|
78
|
-
}
|
|
79
|
-
function n(r) {
|
|
80
|
-
return r * 360 - 180;
|
|
81
|
-
}
|
|
82
|
-
function a(r) {
|
|
83
|
-
return 360 / Math.PI * Math.atan(Math.exp((180 - r * 360) * Math.PI / 180)) - 90;
|
|
84
|
-
}
|
|
85
|
-
})(p || (p = {}));
|
|
86
|
-
var c;
|
|
87
|
-
((l) => {
|
|
88
|
-
l.COUNT = 12, l.DEGREES = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330], l.DEGREES_DEFAULT = 270;
|
|
89
|
-
})(c || (c = {}));
|
|
90
|
-
const d = () => '<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />', y = () => `<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${d()}<span> @arenarium/maps</span></a>`;
|
|
91
|
-
class g {
|
|
92
|
-
constructor(i, e, s, t) {
|
|
93
|
-
this.MapClass = i, this.MapMarkerClass = e, this.options = t, this.map = new this.MapClass(s, {
|
|
94
|
-
...t
|
|
95
|
-
}), (t.attribution || t.attribution == null) && (this.map.addListener("idle", () => {
|
|
96
|
-
this.attributionObserver || (this.attributionObserver = new MutationObserver((n, a) => {
|
|
97
|
-
this.insertAttributionElement(), this.attributionElement != null && (this.updateAttributionElement(), a.disconnect());
|
|
98
|
-
}), this.attributionObserver.observe(s, { childList: !0, subtree: !0 }));
|
|
99
|
-
}), this.map.addListener("bounds_changed", () => {
|
|
100
|
-
this.updateAttributionElement();
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
insertAttributionElement() {
|
|
104
|
-
const i = this.map.getDiv();
|
|
105
|
-
if (i == null) return;
|
|
106
|
-
const e = i.getElementsByClassName("gmnoprint")[0];
|
|
107
|
-
if (e == null || e.parentElement == null) return;
|
|
108
|
-
const s = e.cloneNode(!0), t = s.childNodes.item(0)?.childNodes.item(1)?.childNodes.item(0);
|
|
109
|
-
t != null && (t.title = "", t.innerHTML = y(), e.parentElement.insertBefore(s, e), this.attributionElement = t);
|
|
110
|
-
}
|
|
111
|
-
updateAttributionElement() {
|
|
112
|
-
const i = this.map.getDiv();
|
|
113
|
-
if (i == null) return;
|
|
114
|
-
const e = this.attributionElement?.childNodes.item(0)?.childNodes.item(1);
|
|
115
|
-
e != null && (e.style.display = i.clientWidth > 500 ? "initial" : "none");
|
|
116
|
-
}
|
|
117
|
-
getParameters() {
|
|
118
|
-
return {
|
|
119
|
-
mapSize: 256,
|
|
120
|
-
zoomMin: this.options.minZoom ?? 0,
|
|
121
|
-
zoomMax: this.options.maxZoom ?? 24,
|
|
122
|
-
zoomScale: 10
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
getMap() {
|
|
126
|
-
return this.map;
|
|
127
|
-
}
|
|
128
|
-
getContainer() {
|
|
129
|
-
return this.map.getDiv();
|
|
130
|
-
}
|
|
131
|
-
getZoom() {
|
|
132
|
-
return this.map.getZoom() ?? NaN;
|
|
133
|
-
}
|
|
134
|
-
getBounds() {
|
|
135
|
-
const i = this.map.getBounds();
|
|
136
|
-
if (i == null) return { sw: { lat: NaN, lng: NaN }, ne: { lat: NaN, lng: NaN } };
|
|
137
|
-
const e = i.getSouthWest(), s = i.getNorthEast();
|
|
138
|
-
return { sw: { lat: e.lat(), lng: e.lng() }, ne: { lat: s.lat(), lng: s.lng() } };
|
|
139
|
-
}
|
|
140
|
-
panBy(i, e) {
|
|
141
|
-
this.map.panBy(i, e);
|
|
142
|
-
}
|
|
143
|
-
createMarker(i, e, s, t) {
|
|
144
|
-
const n = new this.MapMarkerClass({ position: { lat: e, lng: s }, content: i, zIndex: t });
|
|
145
|
-
return {
|
|
146
|
-
inserted: () => n.map != null && n.map == this.map,
|
|
147
|
-
insert: () => n.map = this.map,
|
|
148
|
-
remove: () => n.map = void 0,
|
|
149
|
-
update: (a) => n.zIndex = a
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const f = [
|
|
154
|
-
{
|
|
155
|
-
elementType: "labels.icon",
|
|
156
|
-
stylers: [
|
|
157
|
-
{
|
|
158
|
-
visibility: "off"
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
stylers: [
|
|
164
|
-
{
|
|
165
|
-
saturation: -100
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
lightness: -10
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
featureType: "landscape",
|
|
174
|
-
stylers: [
|
|
175
|
-
{
|
|
176
|
-
lightness: 30
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
featureType: "road",
|
|
182
|
-
elementType: "geometry",
|
|
183
|
-
stylers: [
|
|
184
|
-
{
|
|
185
|
-
saturation: -100
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
}
|
|
189
|
-
], M = [
|
|
190
|
-
{
|
|
191
|
-
elementType: "labels.icon",
|
|
192
|
-
stylers: [
|
|
193
|
-
{
|
|
194
|
-
visibility: "off"
|
|
195
|
-
}
|
|
196
|
-
]
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
stylers: [
|
|
200
|
-
{
|
|
201
|
-
saturation: -100
|
|
202
|
-
}
|
|
203
|
-
]
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
elementType: "geometry",
|
|
207
|
-
stylers: [
|
|
208
|
-
{
|
|
209
|
-
lightness: -45
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
elementType: "labels.text.fill",
|
|
215
|
-
stylers: [
|
|
216
|
-
{
|
|
217
|
-
lightness: -100
|
|
218
|
-
}
|
|
219
|
-
]
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
elementType: "labels.text.stroke",
|
|
223
|
-
stylers: [
|
|
224
|
-
{
|
|
225
|
-
lightness: -15
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
featureType: "water",
|
|
231
|
-
elementType: "geometry",
|
|
232
|
-
stylers: [
|
|
233
|
-
{
|
|
234
|
-
lightness: -50
|
|
235
|
-
}
|
|
236
|
-
]
|
|
237
|
-
}
|
|
238
|
-
];
|
|
239
|
-
export {
|
|
240
|
-
M as GoogleMapDarkStyle,
|
|
241
|
-
f as GoogleMapLightStyle,
|
|
242
|
-
g as GoogleMapsProvider
|
|
243
|
-
};
|
package/src/lib/provider.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { getAttributionHtml } from '@arenarium/maps';
|
|
2
|
-
import type { MapProvider, MapProviderParameters, MapProviderMarker, MapBounds } from '@arenarium/maps';
|
|
3
|
-
|
|
4
|
-
interface GoogleMapsClass {
|
|
5
|
-
new (container: HTMLElement, options: google.maps.MapOptions): google.maps.Map;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface GoogleMapsMarkerClass {
|
|
9
|
-
new (options: google.maps.marker.AdvancedMarkerElementOptions): google.maps.marker.AdvancedMarkerElement;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface GoogleMapsOptions extends google.maps.MapOptions {
|
|
13
|
-
attribution?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class GoogleMapsProvider implements MapProvider {
|
|
17
|
-
private MapClass: GoogleMapsClass;
|
|
18
|
-
private MapMarkerClass: GoogleMapsMarkerClass;
|
|
19
|
-
|
|
20
|
-
private map: google.maps.Map;
|
|
21
|
-
private options: google.maps.MapOptions;
|
|
22
|
-
|
|
23
|
-
private attributionObserver: MutationObserver | undefined;
|
|
24
|
-
private attributionElement: HTMLElement | undefined;
|
|
25
|
-
|
|
26
|
-
constructor(mapClass: GoogleMapsClass, mapMarkerClass: GoogleMapsMarkerClass, container: HTMLElement, options: GoogleMapsOptions) {
|
|
27
|
-
this.MapClass = mapClass;
|
|
28
|
-
this.MapMarkerClass = mapMarkerClass;
|
|
29
|
-
|
|
30
|
-
this.options = options;
|
|
31
|
-
this.map = new this.MapClass(container, {
|
|
32
|
-
...options
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (options.attribution || options.attribution == undefined) {
|
|
36
|
-
// Add attribution element
|
|
37
|
-
this.map.addListener('idle', () => {
|
|
38
|
-
if (this.attributionObserver) return;
|
|
39
|
-
|
|
40
|
-
this.attributionObserver = new MutationObserver((_, observer) => {
|
|
41
|
-
// Try to insert attribution element
|
|
42
|
-
this.insertAttributionElement();
|
|
43
|
-
// If insertion failed, return
|
|
44
|
-
if (this.attributionElement == undefined) return;
|
|
45
|
-
// Update attribution element
|
|
46
|
-
this.updateAttributionElement();
|
|
47
|
-
// Disconnect observer
|
|
48
|
-
observer.disconnect();
|
|
49
|
-
});
|
|
50
|
-
this.attributionObserver.observe(container, { childList: true, subtree: true });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
this.map.addListener('bounds_changed', () => {
|
|
54
|
-
// Update attribution element
|
|
55
|
-
this.updateAttributionElement();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private insertAttributionElement() {
|
|
61
|
-
// Get map container
|
|
62
|
-
const container = this.map.getDiv();
|
|
63
|
-
if (container == undefined) return;
|
|
64
|
-
|
|
65
|
-
// Find bottom right attribution elements first child
|
|
66
|
-
const attributionElementsFirstChild = container.getElementsByClassName('gmnoprint')[0];
|
|
67
|
-
if (attributionElementsFirstChild == undefined) return;
|
|
68
|
-
if (attributionElementsFirstChild.parentElement == undefined) return;
|
|
69
|
-
|
|
70
|
-
// Clone attribution element
|
|
71
|
-
const attributionWrapper = attributionElementsFirstChild.cloneNode(true) as HTMLElement;
|
|
72
|
-
|
|
73
|
-
// Find attribution wrapper target child
|
|
74
|
-
const attributionWrapperTargetChild = attributionWrapper.childNodes.item(0)?.childNodes.item(1)?.childNodes.item(0) as HTMLElement;
|
|
75
|
-
if (attributionWrapperTargetChild == undefined) return;
|
|
76
|
-
|
|
77
|
-
// Set attribution wrapper target child inner HTML
|
|
78
|
-
attributionWrapperTargetChild.title = '';
|
|
79
|
-
attributionWrapperTargetChild.innerHTML = getAttributionHtml();
|
|
80
|
-
|
|
81
|
-
// Insert attribution wrapper before attribution elements first child
|
|
82
|
-
attributionElementsFirstChild.parentElement.insertBefore(attributionWrapper, attributionElementsFirstChild);
|
|
83
|
-
|
|
84
|
-
// Assign attribution element
|
|
85
|
-
this.attributionElement = attributionWrapperTargetChild;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private updateAttributionElement() {
|
|
89
|
-
// Get map container
|
|
90
|
-
const container = this.map.getDiv();
|
|
91
|
-
if (container == undefined) return;
|
|
92
|
-
|
|
93
|
-
// Get attribution element span
|
|
94
|
-
const attributionElementSpan = this.attributionElement?.childNodes.item(0)?.childNodes.item(1) as HTMLElement;
|
|
95
|
-
if (attributionElementSpan == undefined) return;
|
|
96
|
-
|
|
97
|
-
// Set attribution element span display
|
|
98
|
-
attributionElementSpan.style.display = container.clientWidth > 500 ? 'initial' : 'none';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public getParameters(): MapProviderParameters {
|
|
102
|
-
return {
|
|
103
|
-
mapSize: 256,
|
|
104
|
-
zoomMin: this.options.minZoom ?? 0,
|
|
105
|
-
zoomMax: this.options.maxZoom ?? 24,
|
|
106
|
-
zoomScale: 10
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public getMap(): google.maps.Map {
|
|
111
|
-
return this.map;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public getContainer(): HTMLElement {
|
|
115
|
-
return this.map.getDiv();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public getZoom(): number {
|
|
119
|
-
return this.map.getZoom() ?? NaN;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public getBounds(): MapBounds {
|
|
123
|
-
const bounds = this.map.getBounds();
|
|
124
|
-
if (bounds == undefined) return { sw: { lat: NaN, lng: NaN }, ne: { lat: NaN, lng: NaN } };
|
|
125
|
-
|
|
126
|
-
const sw = bounds.getSouthWest();
|
|
127
|
-
const ne = bounds.getNorthEast();
|
|
128
|
-
return { sw: { lat: sw.lat(), lng: sw.lng() }, ne: { lat: ne.lat(), lng: ne.lng() } };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public panBy(x: number, y: number): undefined {
|
|
132
|
-
this.map.panBy(x, y);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public createMarker(element: HTMLElement, lat: number, lng: number, zIndex: number): MapProviderMarker {
|
|
136
|
-
const marker = new this.MapMarkerClass({ position: { lat, lng }, content: element, zIndex });
|
|
137
|
-
return {
|
|
138
|
-
inserted: () => marker.map != undefined && marker.map == this.map,
|
|
139
|
-
insert: () => (marker.map = this.map),
|
|
140
|
-
remove: () => (marker.map = undefined),
|
|
141
|
-
update: (zIndex: number) => (marker.zIndex = zIndex)
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
package/src/lib/styles.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export const GoogleMapLightStyle = [
|
|
2
|
-
{
|
|
3
|
-
elementType: 'labels.icon',
|
|
4
|
-
stylers: [
|
|
5
|
-
{
|
|
6
|
-
visibility: 'off'
|
|
7
|
-
}
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
stylers: [
|
|
12
|
-
{
|
|
13
|
-
saturation: -100
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
lightness: -10
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
featureType: 'landscape',
|
|
22
|
-
stylers: [
|
|
23
|
-
{
|
|
24
|
-
lightness: 30
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
featureType: 'road',
|
|
30
|
-
elementType: 'geometry',
|
|
31
|
-
stylers: [
|
|
32
|
-
{
|
|
33
|
-
saturation: -100
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
export const GoogleMapDarkStyle = [
|
|
40
|
-
{
|
|
41
|
-
elementType: 'labels.icon',
|
|
42
|
-
stylers: [
|
|
43
|
-
{
|
|
44
|
-
visibility: 'off'
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
stylers: [
|
|
50
|
-
{
|
|
51
|
-
saturation: -100
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
elementType: 'geometry',
|
|
57
|
-
stylers: [
|
|
58
|
-
{
|
|
59
|
-
lightness: -45
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
elementType: 'labels.text.fill',
|
|
65
|
-
stylers: [
|
|
66
|
-
{
|
|
67
|
-
lightness: -100
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
elementType: 'labels.text.stroke',
|
|
73
|
-
stylers: [
|
|
74
|
-
{
|
|
75
|
-
lightness: -15
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
featureType: 'water',
|
|
81
|
-
elementType: 'geometry',
|
|
82
|
-
stylers: [
|
|
83
|
-
{
|
|
84
|
-
lightness: -50
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
];
|
package/src/main.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"checkJs": true,
|
|
5
|
-
"esModuleInterop": true,
|
|
6
|
-
"forceConsistentCasingInFileNames": true,
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"outDir": "dist",
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationDir": "dist",
|
|
14
|
-
"emitDeclarationOnly": true,
|
|
15
|
-
"module": "NodeNext",
|
|
16
|
-
"moduleResolution": "NodeNext",
|
|
17
|
-
"types": ["vite/client", "./node_modules/@types/google.maps/index.d.ts"]
|
|
18
|
-
}
|
|
19
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import dts from 'vite-plugin-dts';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [
|
|
6
|
-
dts({
|
|
7
|
-
rollupTypes: true,
|
|
8
|
-
insertTypesEntry: true,
|
|
9
|
-
entryRoot: './src',
|
|
10
|
-
copyDtsFiles: true,
|
|
11
|
-
exclude: ['**/node_modules/**']
|
|
12
|
-
})
|
|
13
|
-
],
|
|
14
|
-
build: {
|
|
15
|
-
lib: {
|
|
16
|
-
entry: './src/main.ts',
|
|
17
|
-
name: 'ArenariumMapsIntegrationGoogle',
|
|
18
|
-
formats: ['es', 'cjs'],
|
|
19
|
-
fileName: (format, entryName) => `${entryName}.${format}.js`,
|
|
20
|
-
cssFileName: 'style'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|