Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49526

Ionic 4 code map not work on android but work on ios

$
0
0

@sehsah2020 wrote:

hi,
i need ask about my code it,
show location user and can click in mark to get new location and address
it worked well on web and ios but on android show blank white
why ??? where problem


 ionViewDidLoad() {
    this.platform.ready().then(() => {
      this.loadMap();
    });
  }

loadMap() {

    Environment.setEnv({
      'API_KEY_FOR_BROWSER_RELEASE': '(``)',
      'API_KEY_FOR_BROWSER_DEBUG': ''
    });

    LocationService.getMyLocation().then((myLocation: MyLocation) => {
      let options: GoogleMapOptions = {
        camera: {
          target: myLocation.latLng,
          zoom: 17,
        }
      };
      this.map = GoogleMaps.create('map_canvas', options);
      this.marker = this.map.addMarkerSync({
        title: 'Ionic',
        icon: {
          url: 'assets/images/place2.png',
          size: {
            width: 32,
            height: 32
          }
        },
        position: myLocation.latLng,
      });
      this.marker.on(GoogleMapsEvent.MARKER_CLICK)
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe((data) => {
        this.lat = data['0']['lat']
        this.lat = data['0']['lng']
        console.log(data['0']['lat'], data['0']['lng'])
        localStorage.setItem('latitude', data[0]['lat'])
        localStorage.setItem('longitude', data[0]['lng'])
        localStorage.setItem('district', data[0]['subLocality'])
        this.GetNewlocation(data['0']['lat'], data['0']['lng'])
        this.marker.remove()
        this.marker = this.map.addMarkerSync({
          title: 'Ionic',
          icon: {
            url: 'assets/images/place2.png',
            size: {
              width: 32,
              height: 32
            }
          },
          position: { lat: data['0']['lat'], lng: data['0']['lng'] },
        });
        this.marker.on(GoogleMapsEvent.MARKER_CLICK)
      }
      );

    });

  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>