【发布时间】:2017-05-11 05:02:10
【问题描述】:
试图在 ionic 2 中实现 google maps (native),尝试了各种方法,但都是徒劳的。
试用过:
错误:
Native:尝试访问 GoogleMap 插件但未安装。
安装 GoogleMap 插件:'ionic plugin add plugin.google.maps.Map'
当尝试安装上面的插件时,它会说:
错误:注册表在 https://registry.npmjs.org/plugin.google.maps.Map 上为 GET 返回 404
HTML-
<ion-content padding>
<div #map id="map" ></div>
</ion-content>
JS -
import { Component } from '@angular/core';
import { NavController, NavParams, Platform } from 'ionic-angular';
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native';
@Component({
selector: 'page-store-map',
templateUrl: 'store-map.html'
})
export class StoreMapPage {
map: GoogleMap;
constructor(public navCtrl: NavController,public platform: Platform,
public navParams: NavParams) {
platform.ready().then(() => {
alert('Ready');
this.loadMap();
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad StoreMapPage');
}
loadMap()
{
let location = new GoogleMapsLatLng(-34.9290,138.6010);
this.map = new GoogleMap('map', {
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
},
'camera': {
'latLng': location,
'tilt': 30,
'zoom': 15,
'bearing': 50
}
});
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
console.log('Map is ready!');
});
}
}
有人可以帮助如何继续进行此操作吗?
【问题讨论】:
标签: google-maps ionic2