Last active
June 14, 2021 21:32
-
-
Save runspired/b542325d96f7952c3aa21b61c1094bde to your computer and use it in GitHub Desktop.
TomTom
This file contains hidden or 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
import Component from '@glimmer/component'; | |
export default class extends Component { | |
constructor() { | |
super(...arguments); | |
let m = document.createElement('div'); | |
m.className="tom-tom-map"; | |
this.mapContainer = m; | |
this.map = null; | |
this.initMap(m); | |
} | |
initMap(mapContainer) { | |
const coordinates = [-96.825508, 33.078419]; | |
const map = tt.map({ | |
container: mapContainer, | |
key: 'as6JD8b6ao8CKzrnY0cMa9L2KEjNGNFd', | |
center: coordinates, | |
zoom: 15 | |
}); | |
const marker = new tt.Marker() | |
.setLngLat(coordinates) | |
.addTo(map); | |
this.map = map; | |
} | |
willDestroy() { | |
this.map.remove(); | |
this.mapContainer = null; | |
this.map = null; | |
} | |
} |
This file contains hidden or 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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
This file contains hidden or 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
import Route from '@ember/routing/route'; | |
const CSS_URL = 'https://api.tomtom.com/maps-sdk-for-web/cdn/6.x/6.13.0/maps/maps.css'; | |
const JS_URL = 'https://api.tomtom.com/maps-sdk-for-web/cdn/6.x/6.13.0/maps/maps-web.min.js'; | |
async function importCSS(url) { | |
const link = document.createElement('link'); | |
link.setAttribute('rel', 'stylesheet'); | |
link.setAttribute('type', 'text/css'); | |
link.setAttribute('href', url); | |
document.getElementsByTagName('head')[0].appendChild(link); | |
await new Promise(resolve => { | |
link.onload = resolve; | |
}); | |
} | |
async function importJS(url) { | |
const script = document.createElement('script'); | |
script.src = url; | |
script.type = "text/javascript"; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
await new Promise(resolve => { | |
script.onload = resolve; | |
}); | |
} | |
export default class AppRoute extends Route { | |
async model() { | |
await importCSS(CSS_URL); | |
await importJS(JS_URL); | |
return {}; | |
} | |
} |
This file contains hidden or 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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.tom-tom-map { | |
height: 500px; | |
width: 500px; | |
position: relative; | |
} |
This file contains hidden or 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
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment