infusion-code / angular-maps

Angular Maps (X-Map) is a set of components and services to provide map functionality in angular 2+ apps. X-Maps architecture is provider independent and can be used with Bing, Google, ESRI or any other service enabled mapping provider. X-Map contains a default implementation for Bing Maps.
MIT License
41 stars 34 forks source link

TypeError: this.getMap is not a function V6.0.3 #110

Open LauraTGail opened 5 years ago

LauraTGail commented 5 years ago

Now works with Angular 8, but still getting errors for polygons.

Environment: Angular 8 "angular-maps": "6.0.3" "typescript": "3.5.3"

Issue: core.js:4002 ERROR Error: Uncaught (in promise): TypeError: this.getMap is not a function TypeError: this.getMap is not a function

Annotation 2019-09-17 112755

Polygons are not displaying. Annotation 2019-09-17 112808

quickskape commented 5 years ago

As a workaround, I found that removing the [Title]="'Title Here'" from <x-map-polygon> it would render the polygon correctly. Stack trace seems to show it failing inside the show tooltip code.

thor-schueler commented 5 years ago

Could you put a quick demo of your code together on stackblitz so I can take a look and debug this? The tooltip is implemented via a mapLabel, I suspect this is a timing issue where the label has not yet been added to the map, so the getMap() function has not been added to the prototype yet (remember, bing maps is Javascript). I think simply updating bing-label.ts from

    public GetMap(): Microsoft.Maps.Map {
        return (<any>this).getMap();
    }

to

    public GetMap(): Microsoft.Maps.Map {
        if(! (<any>this).getMap) return null; // or some such
        return (<any>this).getMap();
    }

will do the trick but want to look at it a bit closer first....

thor-schueler commented 5 years ago

See https://github.com/infusion-code/angular-maps/tree/Issue110 as proposed fix. Will validate and publish as soon as I have your sample.

LauraTGail commented 5 years ago

Stackblitz demo: https://stackblitz.com/edit/angular-maps-bug-example

krishtgkk commented 4 years ago

Can you please publish the fix soon. I am getting this error. I was excited to see customStyle implementation but ran into polygon issue.

Thanks krishna

krishtgkk commented 4 years ago

Hi

Is there a way I can do npm install --save "github:infusion-code/angular-maps#Issue110". The above command does not get any of src directory gor me to work on. I need this very urgently.

thor-schueler commented 4 years ago

@krishtgkk Unfortunately, you cannot install from a branch, that is not possible with npm. I am planning to take a look on validating and publishing this Friday. In the meanwhile, you might use the workaround outlined above.

krishtgkk commented 4 years ago

Hi

As suggested I have applied the fix locally. stilll getting errors as cannot set property beneathLabels of undefined. The issue is from BingMapLabel function.

image

Please Help.

thor-schueler commented 4 years ago

Done some more investigation... This issue occurs because the BingMapLabel.getMap() is called before the label has been added to the map. The getMap function is dynamically added by Bing once the label has been added. This seems to be the result of dynamically creating the layers with the ngFor. Will need to investigate some more.

thor-schueler commented 4 years ago

Further investigation shows the error was introduced with 6.0.3 by adding the Extender object to do the mixins. This does not to correctly appear to extend the prototypes of the objects with the mixed in class. This affects labels (used for tooltips) and overlays. I will need to debug this more to find the actual offending code...

quickskape commented 4 years ago

Hi @thor-schueler, any update on this issue? Any there any docs for how to get started debugging the package?

dahovey commented 4 years ago

Any updates on this?