pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='7yXJe'><tr id='7yXJe'><dt id='7yXJe'><q id='7yXJe'><span id='7yXJe'><b id='7yXJe'><form id='7yXJe'><ins id='7yXJe'></ins><ul id='7yXJe'></ul><sub id='7yXJe'></sub></form><legend id='7yXJe'></legend><bdo id='7yXJe'><pre id='7yXJe'><center id='7yXJe'></center></pre></bdo></b><th id='7yXJe'></th></span></q></dt></tr></i><div class="3xqw33e" id='7yXJe'><tfoot id='7yXJe'></tfoot><dl id='7yXJe'><fieldset id='7yXJe'></fieldset></dl></div>

  • <tfoot id='7yXJe'></tfoot>

    <legend id='7yXJe'><style id='7yXJe'><dir id='7yXJe'><q id='7yXJe'></q></dir></style></legend>
      <bdo id='7yXJe'></bdo><ul id='7yXJe'></ul>

        <small id='7yXJe'></small><noframes id='7yXJe'>

      1. Ionic - Google 地方和自動填充位置

        Ionic - Google places and Autocomplete location(Ionic - Google 地方和自動填充位置)
        <legend id='RkHdK'><style id='RkHdK'><dir id='RkHdK'><q id='RkHdK'></q></dir></style></legend>
        • <bdo id='RkHdK'></bdo><ul id='RkHdK'></ul>

            1. <small id='RkHdK'></small><noframes id='RkHdK'>

              <i id='RkHdK'><tr id='RkHdK'><dt id='RkHdK'><q id='RkHdK'><span id='RkHdK'><b id='RkHdK'><form id='RkHdK'><ins id='RkHdK'></ins><ul id='RkHdK'></ul><sub id='RkHdK'></sub></form><legend id='RkHdK'></legend><bdo id='RkHdK'><pre id='RkHdK'><center id='RkHdK'></center></pre></bdo></b><th id='RkHdK'></th></span></q></dt></tr></i><div class="sujfjfv" id='RkHdK'><tfoot id='RkHdK'></tfoot><dl id='RkHdK'><fieldset id='RkHdK'></fieldset></dl></div>
                    <tbody id='RkHdK'></tbody>

                  <tfoot id='RkHdK'></tfoot>
                  本文介紹了Ionic - Google 地方和自動填充位置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在 Ionic 2 的項目上工作,到目前為止我已經實現了地圖,但我無法擺脫這一點.為了將 Google Place 和 Autocomplete 添加到項目中,我需要了解我應該采取的方式.

                  I have work on the project on Ionic 2 and I have implemented the map so far, but I can not get out of that point. I needed to be shown the way I should go in order to add Google Place and Autocomplete to the project.

                  我能做什么?

                  HTML:

                  <ion-row>
                    <ion-item>
                      <ion-label>Search</ion-label>
                      <ion-input id="places" type="text" name="search"></ion-input>       
                  </ion-row>
                  <div #map id="map"></div>
                  

                  HOME.ts

                  export class HomePage {
                  
                  public latitude: number;
                  public longitude: number;
                  
                  @ViewChild('map') mapElement;
                  map: any;
                  marker: any;
                  search: string;
                  
                  constructor(public navCtrl: NavController, public platform: Platform) {
                   /*platform.ready().then(() => {
                    this.InitMap();
                   });*/
                  }
                   ionViewDidLoad(){
                   this.InitMap();
                  }
                  
                  InitMap() {
                  
                    this.setLocation();
                    let input = document.getElementById('places');
                    let autocomplete = new google.maps.places.Autocomplete(input);
                  
                    google.maps.event.addListener(autocomplete, 'place_changed', () => {
                  
                      let place = autocomplete.getPlace();
                      this.latitude = place.geometry.location.lat();
                      this.longitude = place.geometry.location.lng();
                      alert(this.latitude + ", " + this.longitude);
                      console.log(place);
                    });
                  
                  }
                  
                  setLocation() {
                  
                    let latLng = new google.maps.LatLng(53.550513, 9.994241);
                    let mapOptions = {
                      center: latLng,
                      zoom: 15,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                  
                    this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);    
                    this.marker = new google.maps.Marker({
                      position: latLng,
                      map: this.map,
                     });
                    }
                  
                   }
                  

                  怎么了?謝謝

                  推薦答案

                  已解決!很長一段時間后,我能夠找到解決問題的方法.這是解決方案:

                  SOLVED! After a long time I was able to find a solution to my problem. Here's the solution:

                  主頁.html:

                  <ion-list>
                    <ion-item>
                      <ion-input (click)="showAddressModal()" [(ngModel)]="address.place"type="text" placeholder="Pick an address">              </ion-input>
                    </ion-item>
                  </ion-list>
                  

                  Home.ts:

                  import {Component} from '@angular/core';
                  import {NavController, ModalController} from 'ionic-angular';
                  import {AutocompletePage} from './autocomplete';
                  
                  @Component({
                    templateUrl: 'build/pages/home/home.html'
                  })
                  
                  export class HomePage {
                    address;
                  
                    constructor(
                      private navCtrl: NavController,
                      private ModalCtrl:ModalController
                    ) {
                      this.address = {
                        place: ''
                      };
                    }
                  
                    showAddressModal () {
                      let modal = this.modalCtrl.create(AutocompletePage);
                      let me = this;
                      modal.onDidDismiss(data => {
                        this.address.place = data;
                      });
                      modal.present();
                    }
                  }
                  

                  AutocompletePage.html:

                  AutocompletePage.html:

                  <ion-header>
                    <ion-toolbar>
                      <ion-title>Enter address</ion-title>
                      <ion-searchbar [(ngModel)]="autocomplete.query" [showCancelButton]="true"   (ionInput)="updateSearch()" (ionCancel)="dismiss()"></ion-searchbar>
                    </ion-toolbar>
                  </ion-header>
                  
                  <ion-content>
                    <ion-list>
                      <ion-item *ngFor="let item of autocompleteItems" tappable   (click)="chooseItem(item)">
                        {{ item }}
                      </ion-item>
                    </ion-list>
                  </ion-content>
                  

                  AutocompletePage.ts:

                  AutocompletePage.ts:

                  import {Component, NgZone} from '@angular/core';
                  import {ViewController} from 'ionic-angular';
                  
                  @Component({
                    templateUrl: 'build/pages/home/autocomplete.html'
                  })
                  
                  export class AutocompletePage {
                    autocompleteItems;
                    autocomplete;
                  
                    latitude: number = 0;
                    longitude: number = 0;
                    geo: any
                  
                    service = new google.maps.places.AutocompleteService();
                  
                    constructor (public viewCtrl: ViewController, private zone: NgZone) {
                      this.autocompleteItems = [];
                      this.autocomplete = {
                        query: ''
                      };
                    }
                  
                    dismiss() {
                      this.viewCtrl.dismiss();
                    }
                  
                    chooseItem(item: any) {
                      this.viewCtrl.dismiss(item);
                      this.geo = item;
                      this.geoCode(this.geo);//convert Address to lat and long
                    }
                  
                    updateSearch() {
                  
                      if (this.autocomplete.query == '') {
                       this.autocompleteItems = [];
                       return;
                      }
                  
                      let me = this;
                      this.service.getPlacePredictions({
                      input: this.autocomplete.query,
                      componentRestrictions: {
                        country: 'de'
                      }
                     }, (predictions, status) => {
                       me.autocompleteItems = [];
                  
                     me.zone.run(() => {
                       if (predictions != null) {
                          predictions.forEach((prediction) => {
                            me.autocompleteItems.push(prediction.description);
                          });
                         }
                       });
                     });
                    }
                  
                    //convert Address string to lat and long
                    geoCode(address:any) {
                      let geocoder = new google.maps.Geocoder();
                      geocoder.geocode({ 'address': address }, (results, status) => {
                      this.latitude = results[0].geometry.location.lat();
                      this.longitude = results[0].geometry.location.lng();
                      alert("lat: " + this.latitude + ", long: " + this.longitude);
                     });
                   }
                  }
                  

                  這篇關于Ionic - Google 地方和自動填充位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  <legend id='gXn9e'><style id='gXn9e'><dir id='gXn9e'><q id='gXn9e'></q></dir></style></legend>
                      <bdo id='gXn9e'></bdo><ul id='gXn9e'></ul>
                    • <small id='gXn9e'></small><noframes id='gXn9e'>

                        • <i id='gXn9e'><tr id='gXn9e'><dt id='gXn9e'><q id='gXn9e'><span id='gXn9e'><b id='gXn9e'><form id='gXn9e'><ins id='gXn9e'></ins><ul id='gXn9e'></ul><sub id='gXn9e'></sub></form><legend id='gXn9e'></legend><bdo id='gXn9e'><pre id='gXn9e'><center id='gXn9e'></center></pre></bdo></b><th id='gXn9e'></th></span></q></dt></tr></i><div class="hu33xjz" id='gXn9e'><tfoot id='gXn9e'></tfoot><dl id='gXn9e'><fieldset id='gXn9e'></fieldset></dl></div>

                            <tbody id='gXn9e'></tbody>
                          <tfoot id='gXn9e'></tfoot>

                          1. 主站蜘蛛池模板: 合肥制氮机_合肥空压机厂家_安徽真空泵-凯圣精机 | 无痕胶_可移胶_无痕双面胶带_可移无痕胶厂家-东莞凯峰 | 分类168信息网 - 分类信息网 免费发布与查询 | 无压烧结银_有压烧结银_导电银胶_导电油墨_导电胶-善仁(浙江)新材料 | 高硼硅玻璃|水位计玻璃板|光学三棱镜-邯郸奥维玻璃科技有限公司 高温高压釜(氢化反应釜)百科 | 永嘉县奥阳陶瓷阀门有限公司| 震动筛选机|震动分筛机|筛粉机|振筛机|振荡筛-振动筛分设备专业生产厂家高服机械 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 叉车电池-叉车电瓶-叉车蓄电池-铅酸蓄电池-电动叉车蓄电池生产厂家 | 千淘酒店差旅平台-中国第一家针对TMC行业的酒店资源供应平台 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | Win10系统下载_32位/64位系统/专业版/纯净版下载 | 高效节能电机_伺服主轴电机_铜转子电机_交流感应伺服电机_图片_型号_江苏智马科技有限公司 | 上海软件开发-上海软件公司-软件外包-企业软件定制开发公司-咏熠科技 | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 微波萃取合成仪-电热消解器价格-北京安合美诚科学仪器有限公司 | 锡膏喷印机-全自动涂覆机厂家-全自动点胶机-视觉点胶机-深圳市博明智控科技有限公司 | 营养师网,营养师考试时间,报名入口—网站首页 | 电缆桥架生产厂家_槽式/梯式_热镀锌线槽_广东东莞雷正电气 | 华中线缆有限公司-电缆厂|电缆厂家|电线电缆厂家 | 长沙中央空调维修,中央空调清洗维保,空气能热水工程,价格,公司就找维小保-湖南维小保环保科技有限公司 | LINK FASHION 童装·青少年装展| 郑州宣传片拍摄-TVC广告片拍摄-微电影短视频制作-河南优柿文化传媒有限公司 | 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | BHK汞灯-百科|上海熙浩实业有限公司 | 丙烷/液氧/液氮气化器,丙烷/液氧/液氮汽化器-无锡舍勒能源科技有限公司 | 浴室柜-浴室镜厂家-YINAISI · 意大利设计师品牌 | 咿耐斯 |-浙江台州市丰源卫浴有限公司 | 菲希尔FISCHER测厚仪-铁素体检测仪-上海吉馨实业发展有限公司 | 冷镦机-多工位冷镦机-高速冷镦机厂家-温州金诺机械设备制造有限公司 | 热熔胶网膜|pes热熔网膜价格|eva热熔胶膜|热熔胶膜|tpu热熔胶膜厂家-苏州惠洋胶粘制品有限公司 | 折弯机-刨槽机-数控折弯机-数控刨槽机-数控折弯机厂家-深圳豐科机械有限公司 | 专业的新乡振动筛厂家-振动筛品质保障-环保振动筛价格—新乡市德科筛分机械有限公司 | 品牌广告服务平台,好排名,好流量,好生意。 | MOOG伺服阀维修,ATOS比例流量阀维修,伺服阀维修-上海纽顿液压设备有限公司 | 智能垃圾箱|垃圾房|垃圾分类亭|垃圾分类箱专业生产厂家定做-宿迁市传宇环保设备有限公司 | 北京征地律师,征地拆迁律师,专业拆迁律师,北京拆迁律师,征地纠纷律师,征地诉讼律师,征地拆迁补偿,拆迁律师 - 北京凯诺律师事务所 | jrs高清nba(无插件)直播-jrs直播低调看直播-jrs直播nba-jrs直播 上海地磅秤|电子地上衡|防爆地磅_上海地磅秤厂家–越衡称重 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 干培两用箱-细菌恒温培养箱-菲斯福仪器 | 日本细胞免疫疗法_肿瘤免疫治疗_NK细胞疗法 - 免疫密码 | 郑州水质检测中心_井水检测_河南废气检测_河南中环嘉创检测 |