Google maps 在应用程序上显示国家名称
当我试图在浏览器上查看我当前的国家名称时,我会在控制台上收到cordova通知。 在我的tests.html上有什么方法或替代方法可以显示给我,比如在输入字段中(在浏览器中)? 另一方面,如果存在另一种显示实际国家名称的替代方案,请告诉我 测试Google maps 在应用程序上显示国家名称,google-maps,ionic-framework,ionic3,Google Maps,Ionic Framework,Ionic3,当我试图在浏览器上查看我当前的国家名称时,我会在控制台上收到cordova通知。 在我的tests.html上有什么方法或替代方法可以显示给我,比如在输入字段中(在浏览器中)? 另一方面,如果存在另一种显示实际国家名称的替代方案,请告诉我 测试 import { Component, ViewChild, ElementRef } from "@angular/core"; import { NavController, IonicPage, NavParams } from "ionic-an
import { Component, ViewChild, ElementRef } from "@angular/core";
import { NavController, IonicPage, NavParams } from "ionic-angular";
import {
NativeGeocoder,
NativeGeocoderReverseResult
} from "@ionic-native/native-geocoder";
import { Geolocation } from "@ionic-native/geolocation";
declare var google;
@IonicPage()
@Component({
selector: "page-tests",
templateUrl: "tests.html"
})
export class TestsPage {
@ViewChild("mapSmall") mapElement: ElementRef;
map: any;
message: any;
location: any;
gmLocation: { lat: number; lng: number } = { lat: 0, lng: 0 };
constructor(
public navCtrl: NavController,
private geolocation: Geolocation,
private nativeGeocoder: NativeGeocoder,
public navParams: NavParams,
) {
this.onLocateUser();
}
onLocateUser() {
this.geolocation
.getCurrentPosition()
.then(location => {
console.log(
"position gotten: long:",
location.coords.longitude,
" lat:",
location.coords.latitude
);
this.location = location;
this.gmLocation.lat = location.coords.latitude;
this.gmLocation.lng = location.coords.longitude;
this.nativeGeocoder.reverseGeocode(location.coords.latitude,location.coords.longitude)
.then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result.countryName)))
.catch((error: any) => console.log(error));
})
.catch(error => {
console.log("Error getting location", error);
});
}
ionViewDidLoad() {
let latlng = new google.maps.LatLng(
this.gmLocation.lat,
this.gmLocation.lat
);
setTimeout(() => {
this.loadMap(latlng);
this.addMarker(this.gmLocation.lat, this.gmLocation.lng);
}, 100);
}
...
}
您在设备上试用过吗?Native只能在设备上使用或添加plaform浏览器。@ImdadAli,我怎么做?
ionic cordova运行android
确保设备已连接到计算机,以确保键入cmd中的adb设备