Angular 将谷歌地图坐标从第一页传递到第二页,并根据该坐标显示地图

Angular 将谷歌地图坐标从第一页传递到第二页,并根据该坐标显示地图,angular,typescript,google-maps,ionic-framework,ionic3,Angular,Typescript,Google Maps,Ionic Framework,Ionic3,我正在使用谷歌地图开发Ionic应用程序。 在应用程序中,我们有2个页面,上面有一些数据 第一页包含谷歌地图,点击它重定向到 第二页 第二页包含带有国家/地区列表和选择按钮的下拉列表 在选择任何国家时,它会获取其坐标并重定向到第一页 所以在第一页,我想用收到的坐标显示地图 任何人都知道如何做到这一点 首页 goToMyLocation(){ this.map.clear(); // Get the location of you this.map.getMyLocation().then((l

我正在使用谷歌地图开发Ionic应用程序。 在应用程序中,我们有2个页面,上面有一些数据

  • 第一页包含谷歌地图,点击它重定向到 第二页

  • 第二页包含带有国家/地区列表和选择按钮的下拉列表

  • 在选择任何国家时,它会获取其坐标并重定向到第一页
  • 所以在第一页,我想用收到的坐标显示地图
  • 任何人都知道如何做到这一点

  • 首页

    goToMyLocation(){
    this.map.clear();
    
    // Get the location of you
    this.map.getMyLocation().then((location: MyLocation ) => {
      console.log(JSON.stringify(location, null ,2));
      this.map.animateCamera({
    
      // Move the map camera to the location with animation
      target:{
        lat: location.latLng.lat,
        lng:location.latLng.lng 
      },
        zoom: 17,
        duration: 500
      });
    
      //add a marker
      let marker: Marker = this.map.addMarkerSync({
        position:{
          lat: location.latLng.lat,
          lng:location.latLng.lng 
        },
        animation: GoogleMapsAnimation.DROP
      });
    
      //show the infoWindow
      marker.showInfoWindow();
    
      this.map.on(GoogleMapsEvent.MAP_READY).subscribe(
        (data) => {
            console.log("Click MAP",data);
        }
      );
    
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe(
        (data) => {
            console.log("Click MAP",data);
            this.navCtrl.push('SelectGeolocationPage');
        }
      );
    
    })
    .catch(err => {
      //this.loading.dismiss();
      // this.showToast(err.error_message);
      console.log(err.error_message)
    
    }); }
    
  • 第二页

    setAsMyLocation(Country: any, State: any) {
    
        coordinatesData // It gives coordinates
    
        this.navCtrl.push(this.page, {  
                    data: Country,
                    State,
        });
    }
    
  • 上面的页面获取坐标并重定向到第一页


    所以我想在第一页中使用这些坐标来显示地图。

    如果没有看到您的代码,很难说出任何内容。你们能分享你们到目前为止做了什么吗?问题更新了。若不看你们的代码,很难说出任何事情。你能分享你到目前为止做了什么吗?问题更新。