Skip to content
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

My map takes long before loading after navigating from another page. #325

Open
kennedyngigi4 opened this issue Jul 21, 2020 · 1 comment

Comments

@kennedyngigi4
Copy link

kennedyngigi4 commented Jul 21, 2020

I have a problem, my map is in the home page and I have other pages eg: favorites, support etc.
If I navigate from example: favorites to home the map takes more than a minute before loading.
What could be the issue?
here is part of the code.

ngOnInit() {
      this.getRegisteredPartners(); 
}
  
  getRegisteredPartners(){
    this.mapservice.getPartners().subscribe((partnerData) => {
      this.registeredPartners = partnerData.map((data) => {
        return{
          id: data.payload.doc.id,
          location: data.payload.doc.data()['bizLocation'],
          lat: data.payload.doc.data()['Lat'],
          lng: data.payload.doc.data()['Lng'],
          mobile: data.payload.doc.data()['mobile'],
          title: data.payload.doc.data()['name'],
          registration: data.payload.doc.data()['registered'],
          verified: data.payload.doc.data()['active_state'],
          garaPic: data.payload.doc.data()['garaPicture'],
          infoDesc: data.payload.doc.data()['infoDesc'],
          weekdays: data.payload.doc.data()['weekdays'],
          sat: data.payload.doc.data()['sat'],
          sun: data.payload.doc.data()['sun'],
          icon: data.payload.doc.data()['icon'],
          mainservice: data.payload.doc.data()['myService']
        }
      });
      this.loadMap();
    })
  }
  
  loadMap(){
    let options: GoogleMapOptions = {
      zoom: 13,
      controls: {
        'compass': false,
        'indoorPicker': true,
        'mapToolbar': true,
        'myLocation': true,
        'myLocationButton': true,
        'zoom': true,
      },
    }
    this.map = GoogleMaps.create('map_canvas', options);

    this.map.on(GoogleMapsEvent.MAP_READY).subscribe((success) => {

      //remove google maps labels and markers;
      let styles = {
        hide: [
          {
            featureType: 'poi.business',
            stylers: [{visibility: 'off'}]
          },
          {
            featureType: 'transit',
            elementType: 'labels.icon',
            stylers: [{visibility: 'off'}]
          }
        ]
      }
      this.map.setOptions({ styles: styles['hide']});
      this.checkGPSPermission();
    });
  }
@wf9a5m75
Copy link
Contributor

Map is not a HTML element, it's a native view.
It takes little time to prepare many things.

You can create a map without attaching map div, then involve map.setDiv()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants