I'm currently working on creating a Bing component in Angular 4, but I'm facing issues with rendering the map.
Below is my index.html file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Microsoft</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=experimental'></script>
</head>
<body onload="AppComponent.helloWorld()">
<div id="myMap"></div>
<app-root></app-root>
</body>
</html>
Here is my component:
export class AppComponent implements OnInit {
@ViewChild('myMap') myMap;
title = 'app';
ngOnInit() {
if(Microsoft !== undefined){
var map = new Microsoft.Maps.Map(this.myMap.nativeElement, {
credentials: 'key goes here'
});
}}
}
And this is my component's HTML file:
<div #myMap style='width: 100%; height: 500px;'></div>
I'm struggling to figure out why the map isn't loading. I keep getting a 'cannot read property 'prototype' of null' error.