I'm trying to use the Bing JavaScript Map control in a new (3.0.0-preview6.19307.2) Blazor server-side application. I have had this working on earlier versions of Blazor and in a client-side application.
The current Blazor JavaScript interop guide does not suggest that any new steps are required but when I add the following section in the body of _Hosts.cshtml and call the createMap function I get an error saying
Microsoft.AspNetCore.Components.Browser.Rendering.RemoteRenderer:
Warning: Unhandled exception rendering component: 'Microsoft' is not defined
ReferenceError: 'Microsoft' is not defined at window.createMap (https://localhost:44372/:79:9)
<script type="text/javascript" src="http://www.bing.com/api/maps/mapcontrol"></script>
<script>
var map = null;
window.createMap = (data) => {
if (map != null)
return;
map = new Microsoft.Maps.Map('#myMap',
{
credentials: '... my credentials ...',
zoom: 1
}
);
Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap');
return ;
};
</script>
This code does work correctly when placed in the index.html of an equivalent client-size Blazor project so I'm guessing some extra step is required to export the map into the Microsoft name-space. Can anyone suggest what I am missing?