microsoft/Bing-Maps-V8-TypeScript-Definitions

this in CustomOverlay prototype methods

Spown opened this issue · 7 comments

Spown commented

It is probably not only CustomOverlay problem but with all utilities doing similar staff, but in my case its CustomOverlay. It would be nice to be able to access the CustomOverlay members from this when inside constructional methods like onAdd, onLoad, onRemove...

Thank you.

I'll try experimenting, but not sure if I'll be able to get the definitions to work in that way.

Spown commented

Much obliged! I also have started a question on Stack Overflow regarding a workaround, but maybe it can yield some useful insights into the problem anyway.

Just tried this with the HtmlPushpinLayer sample in Visual Studio 2017 and this works as you would want it:

getmaptooltip

Here is the HtmlPushpinLayer Typescript file for reference: https://github.com/Microsoft/BingMapsV8CodeSamples/blob/master/Samples/Custom%20Overlays/HtmlPushpinLayer/HtmlPushpinLayerModule.ts

Looks like you might be using the typescript definitions in JavaScript. If that is the case, this is likely a limitation of JavaScript intellisense in Visual Studio. Note that TypeScript definition support for JavaScript is relatively new in Visual Studio.

Spown commented

Well, I'm using VSCode, not VS and it used d.ts all along. But yeah, as I suspected, when consuming it with pure js in the way it is shown in the docs it wouldn't produce Intellisense for this. I probably can rewrite my module in ts (not that I'm any good at it) and then transpile it back to js, but at this point I'm better off just reading docs. Intellisense isn't worth that much pain.

Thank you anyway.

Just a tip, the code samples in MSDN are fairly static, which the code samples here: http://bingmapsv8samples.azurewebsites.net/ are constant evolving and being improved.

Spown commented

Oh, thanks, this should be helpful!