Skip to content

Commit c1b26c9

Browse files
committed
feat(google-maps): Refactored options and added feature to update the map options
1 parent 262a5e4 commit c1b26c9

14 files changed

Lines changed: 877 additions & 1028 deletions

File tree

README.md

Lines changed: 100 additions & 44 deletions
Large diffs are not rendered by default.

example-app/src/pages/Map/ConfigMap.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useState } from 'react';
22
import { GoogleMap } from '@capacitor/google-maps';
3-
import { MapType } from '@capacitor/google-maps';
43
import { IonButton, IonTextarea } from '@ionic/react';
54
import BaseTestingPage from '../../components/BaseTestingPage';
65

@@ -87,10 +86,10 @@ const ConfigMapPage: React.FC = () => {
8786
setCommandOutput("");
8887
try {
8988
const map1 = maps[0];
90-
await map1.setMapType(MapType.Terrain)
89+
await map1.update({ mapTypeId: 'terrain' })
9190

9291
const map2 = maps[1];
93-
await map2.setMapType(MapType.Satellite)
92+
await map2.update({ mapTypeId: 'satellite' })
9493
} catch(err: any) {
9594
setCommandOutput(err.message);
9695
}
@@ -111,7 +110,7 @@ const ConfigMapPage: React.FC = () => {
111110
animate: true,
112111
animationDuration: 50,
113112
})
114-
await map1.enableIndoorMaps(true);
113+
await map1.update({ isIndoorMapsEnabled: true });
115114
} catch(err: any) {
116115
setCommandOutput(err.message);
117116
}
@@ -121,15 +120,15 @@ const ConfigMapPage: React.FC = () => {
121120
setCommandOutput("");
122121
try {
123122
const map1 = maps[0];
124-
await map1.enableTrafficLayer(true);
123+
await map1.update({ isTrafficLayerEnabled: true });
125124
await map1.setCamera({
126125
zoom: 10,
127126
animate: true,
128127
animationDuration: 50,
129128
})
130129

131130
const map2 = maps[0];
132-
await map2.enableTrafficLayer(true);
131+
await map2.update({ isTrafficLayerEnabled: true });
133132
} catch(err: any) {
134133
setCommandOutput(err.message);
135134
}
@@ -139,10 +138,10 @@ const ConfigMapPage: React.FC = () => {
139138
setCommandOutput("");
140139
try {
141140
const map1 = maps[0];
142-
await map1.enableTrafficLayer(false);
141+
await map1.update({ isTrafficLayerEnabled: false });
143142

144143
const map2 = maps[0];
145-
await map2.enableTrafficLayer(false);
144+
await map2.update({ isTrafficLayerEnabled: false });
146145
} catch(err: any) {
147146
setCommandOutput(err.message);
148147
}
@@ -171,15 +170,15 @@ const ConfigMapPage: React.FC = () => {
171170
animate: true,
172171
animationDuration: 50,
173172
})
174-
await map1.enableCurrentLocation(true);
173+
await map1.update({ isMyLocationEnabled: true });
175174

176175
const map2 = maps[1];
177176
await map2.setCamera({
178177
zoom: 1,
179178
animate: true,
180179
animationDuration: 50,
181180
});
182-
await map2.enableCurrentLocation(true);
181+
await map2.update({ isMyLocationEnabled: true });
183182
} catch(err: any) {
184183
setCommandOutput(err.message);
185184
}
@@ -189,10 +188,10 @@ const ConfigMapPage: React.FC = () => {
189188
setCommandOutput("");
190189
try {
191190
const map1 = maps[0];
192-
await map1.enableCurrentLocation(false);
191+
await map1.update({ isMyLocationEnabled: false });
193192

194193
const map2 = maps[1];
195-
await map2.enableCurrentLocation(false);
194+
await map2.update({ isMyLocationEnabled: false });
196195
} catch(err: any) {
197196
setCommandOutput(err.message);
198197
}
@@ -202,10 +201,10 @@ const ConfigMapPage: React.FC = () => {
202201
setCommandOutput("");
203202
try {
204203
const map1 = maps[0];
205-
await map1.enableAccessibilityElements(true);
204+
await map1.update({ isAccessibilityElementsEnabled: true });
206205

207206
const map2 = maps[1];
208-
await map2.enableAccessibilityElements(true);
207+
await map2.update({ isAccessibilityElementsEnabled: true });
209208
} catch(err: any) {
210209
setCommandOutput(err.message);
211210
}
@@ -215,10 +214,10 @@ const ConfigMapPage: React.FC = () => {
215214
setCommandOutput("");
216215
try {
217216
const map1 = maps[0];
218-
await map1.enableAccessibilityElements(false);
217+
await map1.update({ isAccessibilityElementsEnabled: false });
219218

220219
const map2 = maps[1];
221-
await map2.enableAccessibilityElements(false);
220+
await map2.update({ isAccessibilityElementsEnabled: false });
222221
} catch(err: any) {
223222
setCommandOutput(err.message);
224223
}

example-app/src/pages/Markers/MultipleMarkers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const MultipleMarkers: React.FC = () => {
210210
animate: true,
211211
animationDuration: 50,
212212
});
213-
await map?.enableCurrentLocation(true);
213+
await map?.update({ isMyLocationEnabled: true });
214214
}
215215

216216
async function showCurrentBounds() {

0 commit comments

Comments
 (0)