New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property #23
Comments
You need to load the spatial math module first. Here is a code sample https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#calculateHeading+JS |
I tried using the example above, but now I'm getting a "Microsoft.Maps.loadModule is not a function" error. My code below
|
Have you added a script tag to load the bing maps API? The typescript definitions only define the API interface and doesn't contain the source code for the API. Here is a full sample https://msdn.microsoft.com/en-us/library/mt750637.aspx |
How do you go about that in typescript? I am developing in Angular 4. Below is what I think you are talking about
|
That only loads the typescript definition, not the API code itself. You need to load the map script tag in html, or dynamically load it. Here is an angular 1.6 example to give you an idea https://github.com/Microsoft/BingMapsV8CodeSamples/tree/master/Samples/Other/Angular16 |
I added this to my html layout for my component, but I am still receiving the same error.
|
Do you have a GetMap function? As the code you are using specifies that as a callback. Try removing the callback as well as async defer from the script tag. |
That does not solve the problem. Are there any examples of anyone using Bing Maps API in an Angular 2+ application? |
Yes, lots. Please do a search in a search engine. There is also several full end to end components on github as well. I'm on vacation without a computer so a bit limited in terms of putting together code samples. |
I am trying to use the SpatialMath class of the Bing Maps API, but when I try and use it below I am getting this error. "Uncaught TypeError: Cannot read propert of 'getHeading' of undefined.
`locs = this.generatePolylinePointsWithArrow(locs, numArrows, arrowLength);
I suspect this is because my file hasn't loaded SpatialMath yet, but I still don't know how to resolve this issue.
I have these two lines at the top of my file
/// <reference path="..\..\..\..\..\..\node_modules\bingmaps\scripts\MicrosoftMaps\Modules\SpatialMath.d.ts"/> /// <reference path="..\..\..\..\..\..\node_modules\bingmaps\scripts\MicrosoftMaps\Microsoft.Maps.d.ts"/>
The text was updated successfully, but these errors were encountered: