首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在ionic2项目上安装路由传单

在ionic2项目上安装路由传单
EN

Stack Overflow用户
提问于 2017-10-26 12:37:28
回答 1查看 443关注 0票数 0

我已经安装了一个非常基本的ionic2项目,它支持传单(https://github.com/SBejga/ionic2-map-leaflet)。然后我处决了

代码语言:javascript
复制
sudo npm install --save leaflet-routing-machine

为了安装传单布线机。在map.ts上,我得到了以下代码:

代码语言:javascript
复制
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路由错误:对象

我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2017-10-27 07:19:29

要在chrome上运行,请安装chrome插件允许控制允许原点并启用它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46954551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档