question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapView is undefined in Angular component

See original GitHub issue

Hi,

I am using MapView in angular template. I have followed all steps as mentioned in the main page of the repository:

  1. registerElement("MapView", () => MapView);
  2. Added @ViewChild("MapView") mapView: MapView to the properties of angular component class
  3. Added it to component template <GridLayout> <MapView (mapReady)="onMapReady($event)"></MapView> </GridLayout>

The map displays and active. But i can’t add markers and other stuff to the map because my this.mapView property is undefined.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
merigoldcommented, Mar 21, 2018

Use like this:

 @ViewChild("MapView") mapView: ElementRef;

    //Map events
    onMapReady = (event) => {
        console.log("Map Ready");
    };
  
    get mapView():MapView{
        this._mapView.nativeElement;
    }
1reaction
MichaelSolaticommented, Jan 26, 2017

Yea, the method described in the doc didn’t work for me. Instead, in on the onMapReady() function do this…

  private onMapReady(args): void {
    this.mapView = args.object;
  }

And replace @ViewChild("MapView") mapView: MapView; with private mapView: MapView;

You should be all set then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular property showing as undefined [closed] - Stack Overflow
It seems that the data is loaded via a service but when we try to access the specific properties in a loop, it...
Read more >
Cannot read property 'setTransform' of undefined
I try to develop arcgis api application with angular-esri-components solution. I get 「Cannot read property 'setTransform' of undefined」 ...
Read more >
MapView | API Reference | ArcGIS Maps SDK for JavaScript ...
For a map to be visible to the user in the DOM, a MapView must be created and reference a minimum of two...
Read more >
React Google Maps Api Style Guide
The two basic components required to load a simple map are: LoadScript - Loads the Google Maps API script ... preventGoogleFontsLoading, boolean |...
Read more >
Introduction to React Native Maps - LogRocket Blog
If the value of the current property is undefined , that means the component is not yet mounted. Now, you can access any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found