Giter VIP home page Giter VIP logo

Comments (7)

TheMarex avatar TheMarex commented on June 19, 2024

You need to load it from a local http server. For that occasions I have a small script:
https://gist.github.com/TheMarex/b5a44fa78a036a42f1a2
That starts up a http server in the current directory which listens on https://127.0.0.1:8337

from osrm-frontend.

danyeaw avatar danyeaw commented on June 19, 2024

Thanks for sharing the script, that works great to get the frontend working locally. Do you know what part of the frontend requires a httpd? I am interested in using it for a mobile routing application using cordova, but loading a httpd on the phone probably isn't a good solution.

from osrm-frontend.

perliedman avatar perliedman commented on June 19, 2024

One of the primary issues is probably that the OSRM server is referred by a protocol relative URL (//router.project-osrm.org/viaroute rather than for example http://router.project-osrm.org/viaroute) which causes problem when the page is loaded from file://. You can fix this by overriding the serviceUrl option to the router instance (L.Routing.OSRM).

However, there are other things that break when you use file://, such as not being able to load things with XHR even locally without running into cross-site issues in normal browsers. I have no idea how Cordova deals with this, but I guess there must be a way to load local assets with XHR.

from osrm-frontend.

danyeaw avatar danyeaw commented on June 19, 2024

Thanks perliedman! Changing from a relative URL to a complete URL allows it to work properly without a httpd locally. Now I need to work on getting it working with Cordova.

from osrm-frontend.

DennisOSRM avatar DennisOSRM commented on June 19, 2024

@TheMarex Is this something we should fix, too?

from osrm-frontend.

TheMarex avatar TheMarex commented on June 19, 2024

@DennisOSRM nothing to fix on our side. Running from file:// is just a bad idea in general.

from osrm-frontend.

DennisOSRM avatar DennisOSRM commented on June 19, 2024

Alright, fair enough. We should add a section to the readme explaining how to run locally and what dependencies that carries.

from osrm-frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.