Skip to content

Commit 6f6ff2c

Browse files
authored
fix: resolve terradraw build errors, eslint warnings, and loader format (#1547)
1 parent 0630c0c commit 6f6ff2c

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

samples/map-drawing-terradraw/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This sample demonstrates a basic implementation of Terra Draw with the Google Ma
55
![Roadmap View](./screenshots/draw-roadmap.png)
66
![Satellite View](./screenshots/draw-satellite.png)
77

8-
# Google Maps JavaScript Sample
8+
## Google Maps JavaScript Sample
99

1010
## map-drawing-terradraw
1111

samples/map-drawing-terradraw/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
<head>
1010
<title>Terra Draw with Google Maps API Sample</title>
1111
<link rel="stylesheet" href="./style.css" />
12-
<!-- Terra Draw CSS (if any needed, add here) -->
12+
<script type="module" src="./index.ts"></script>
13+
<script>
14+
// prettier-ignore
15+
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
16+
key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8"
17+
});
18+
</script>
1319
</head>
1420
<body>
1521
<!-- Map Container -->
@@ -83,11 +89,6 @@
8389
style="display: none"
8490
accept=".geojson,.json" />
8591
</div>
86-
87-
<script type="module" src="./index.ts"></script>
88-
<!-- prettier-ignore -->
89-
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
90-
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly" });</script>
9192
</body>
9293
</html>
9394
<!--[END maps_map_drawing_terradraw]-->

samples/map-drawing-terradraw/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function setupModeButtons(): void {
9393
setActiveButton(buttonId);
9494
const modeName = modeButtons[buttonId];
9595

96+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
9697
if (!draw) {
9798
return;
9899
}
@@ -133,15 +134,15 @@ function initUI(): void {
133134
}
134135

135136
let map: google.maps.Map;
136-
let draw: TerraDraw;
137+
let draw!: TerraDraw;
137138
const history: GeoJSONStoreFeatures[][] = [];
138139
let redoHistory: GeoJSONStoreFeatures[][] = [];
139140
let selectedFeatureId: string | null = null;
140141
let isRestoring = false;
141142
let resizingEnabled = false;
142143
let debounceTimeout: number | undefined;
143144

144-
async function initMap() {
145+
async function init() {
145146
try {
146147
const { Map } = await google.maps.importLibrary('maps');
147148

@@ -162,6 +163,7 @@ async function initMap() {
162163
map = new Map(mapDiv, mapOptions);
163164

164165
map.addListener('click', () => {
166+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
165167
if (draw) {
166168
console.log('Current draw mode on map click:', draw.getMode());
167169
}
@@ -593,5 +595,5 @@ async function initMap() {
593595
}
594596
}
595597

596-
void initMap();
598+
void init();
597599
// [END maps_map_drawing_terradraw]

samples/map-drawing-terradraw/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "Basic sample for Terra Draw with Google Maps API.",
55
"scripts": {
6-
"build": "tsc && bash ../jsfiddle.sh map-drawing-terradraw && bash ../app.sh map-drawing-terradraw && bash ../docs.sh map-drawing-terradraw && npm run build:vite --workspace=. && bash ../dist.sh map-drawing-terradraw",
6+
"build": "bash ../build-single.sh",
77
"test": "tsc && npm run build:vite --workspace=.",
88
"start": "tsc && vite build --base './' && vite",
99
"build:vite": "vite build --base './'",

0 commit comments

Comments
 (0)