我已经安装了一个非常基本的ionic2项目,它支持传单(https://github.com/SBejga/ionic2-map-leaflet)。然后我处决了
sudo npm install --save leaflet-routing-machine为了安装传单布线机。在map.ts上,我得到了以下代码:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import "leaflet";
import "leaflet-routing-machine"
declare var L: any;
/*
Generated class for the Map page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-map',
templateUrl: 'map.html'
})
export class MapPage {
map: L.Map;
center: L.PointTuple;
constructor(public navCtrl: NavController, public navParams: NavParams) {}
ionViewDidLoad() {
console.log('ionViewDidLoad MapPage');
//set map center
//this.center = [48.137154, 11.576124]; //Munich
this.center = [48.775556, 9.182778]; //Stuttgart
//setup leaflet map
this.initMap();
L.Routing.control({
waypoints: [
L.latLng(48.776, 9.183),
L.latLng(48.786, 9.193)
]
}).addTo(this.map);
}
initMap() {
this.map = L.map('map', {
center: this.center,
zoom: 13
});
//Add OSM Layer
L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
.addTo(this.map);
}
}这张地图似乎装填得很好,但我没有得到任何安排。在控制台中,我收到消息:
router.project-osrm.org/route/v1/driving/9.183,48.776;9.193,48.786?overview=false&alternatives=true&steps=true&hints=;未能加载资源:服务器响应的状态为503 (服务不可用:后端服务器已达到容量)本地主机/:1未能加载https://router.project-osrm.org/route/v1/driving/9.183,48.776;9.193,48.786?overview=false&alternatives=true&steps=true&hints=;:请求的资源上不存在“访问控制-允许-原产地”标头。因此,“http://localhost:8100”源是不允许访问的。响应具有HTTP状态代码503。传单-路由-Machine.js:10477路由错误:对象
我做错了什么吗?
发布于 2017-10-27 07:19:29
要在chrome上运行,请安装chrome插件允许控制允许原点并启用它。
https://stackoverflow.com/questions/46954551
复制相似问题