Skip to content

Commit 992868f

Browse files
committed
fix
1 parent d41ef8a commit 992868f

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,30 @@ yarn add svelte-google-maps-api
2929
Get your Google Maps API Key. Make sure the "Maps JavaScript API" is enabled for your key in the Google Cloud Console. You might also need to enable specific libraries (like "marker", "places", "visualization") depending on the components you use.
3030

3131
```svelte
32-
<!-- src/routes/+page.svelte -->
3332
<script lang="ts">
3433
import {
3534
APIProvider,
3635
GoogleMap,
3736
Marker
3837
} from 'svelte-google-maps-api';
3938
40-
let apiKey = 'YOUR_GOOGLE_MAPS_API_KEY'; // Replace with your actual API key
39+
let apiKey = 'YOUR_GOOGLE_MAPS_API_KEY';
4140
42-
// Map options
4341
const mapOptions = {
44-
center: { lat: 35.681, lng: 139.767 }, // Tokyo Station
42+
center: { lat: 35.681, lng: 139.767 },
4543
zoom: 14,
46-
mapId: 'YOUR_MAP_ID' // Optional: Recommended for Advanced Markers & custom styling
44+
mapId: 'YOUR_MAP_ID'
4745
};
4846
49-
// Marker position
5047
const markerPosition = { lat: 35.681, lng: 139.767 };
51-
5248
</script>
5349
5450
<div style="height: 100vh; width: 100%">
55-
{#if apiKey}
56-
<APIProvider {apiKey} libraries={['marker']}> {/* Load necessary libraries */}
57-
<GoogleMap {...mapOptions} mapContainerStyle="width:100%; height:100%;">
58-
<Marker position={markerPosition} title="Tokyo Station" />
59-
</GoogleMap>
60-
</APIProvider>
61-
{:else}
62-
<p>Please provide an API Key.</p>
63-
<!-- Basic input example (replace with your actual key management) -->
64-
<input type="text" placeholder="Enter API Key" bind:value={apiKey} />
65-
{/if}
51+
<APIProvider {apiKey} libraries={['marker']}> {/* Load necessary libraries */}
52+
<GoogleMap {...mapOptions} mapContainerStyle="width:100%; height:100%;">
53+
<Marker position={markerPosition} title="Tokyo Station" />
54+
</GoogleMap>
55+
</APIProvider>
6656
</div>
6757
```
6858

0 commit comments

Comments
 (0)