-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(maps): fix inline svg urls (#1324)
* fix(maps): fix inline svg urls * chore: format file
- Loading branch information
Showing
5 changed files
with
91 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@baloise/design-system-components': patch | ||
--- | ||
|
||
**maps**: fix image inline svg urls for the legacy marker api. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!doctype html> | ||
<html dir="ltr" lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||
<style> | ||
#map { | ||
height: 100%; | ||
} | ||
html, | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
<script> | ||
var exports = {} | ||
</script> | ||
<script src="https://unpkg.com/@googlemaps/[email protected]/dist/index.min.js"></script> | ||
<script module src="/assets/maps.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="map"></div> | ||
<script> | ||
const position = { lat: -25.344, lng: 131.031 } | ||
|
||
const mapOptions = { | ||
mapId: 'DEMO_MAP_ID', | ||
center: position, | ||
zoom: 4, | ||
styles: exports.balMapTypeStyles, | ||
} | ||
|
||
const loader = new google.maps.plugins.loader.Loader({ | ||
apiKey: '--your-api-key--', | ||
version: 'weekly', | ||
libraries: ['places'], | ||
}) | ||
|
||
let map | ||
loader.importLibrary('maps').then(({ Map }) => { | ||
map = new Map(document.getElementById('map'), mapOptions) | ||
|
||
loader.importLibrary('marker').then(({ AdvancedMarkerElement, Marker }) => { | ||
// Legacy | ||
new Marker({ | ||
map, | ||
position: { lat: -33.8688, lng: 151.2093 }, | ||
title: 'Sydney', | ||
icon: { | ||
url: exports.balMapMarkerDefault, | ||
}, | ||
}) | ||
|
||
const parser = new DOMParser() | ||
const pinSvgString = exports.balMapMarkerDefault.replace('data:image/svg+xml;utf-8, ', '') | ||
const pinSvg = parser.parseFromString(pinSvgString, 'image/svg+xml').documentElement | ||
new AdvancedMarkerElement({ | ||
map, | ||
position, | ||
title: 'Uluru', | ||
content: pinSvg, | ||
}) | ||
}) | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.