0

My goal is to takes real-world map/streets and create custom roads, apply a way to navigate through my own roads along with existing streets in the world After creating a new street, i exported the osm file, brought it to Maperitive to generate the tiles. i then make use of leaflet routing machine to do navigation through my new street in HTML. However, it seems to completely ignore what i have added. I am new into these software and cant seem to find what did i do wrong

Download from OSM into JOSM, created new street. Exported as OSM, opened in Maperitive. Export into Tiles, use Leaflet & Leaflet routing machine to try and route within the new street.

     <link rel="stylesheet" href="Map Navigation/leaflet.css" />
     <link rel="stylesheet" href="Map Navigation/leaflet-routing-machine-3.2.12/dist/leaflet-routing-machine.css" />
     <script src="Map Navigation/leaflet.js"></script>
</head>
<body>
      <div style="width: 1200px; height: 800px" id="map"></div>
      <script type="text/javascript" src="Map Navigation/leaflet-src.js"></script>
      <script src="Map Navigation/leaflet-routing-machine-3.2.12/dist/leaflet-routing-machine.js"></script>
      <script>
    var mymap = L.map('map').setView([1.269506, 103.832759], 13);

L.tileLayer('Map Navigation/Tiles/{z}/{x}/{y}.png', {maxZoom: 16}).addTo(mymap);


L.Routing.control({ waypoints:[
L.latLng(1.269506, 103.832759),
L.latLng(1.269542, 103.835772)],
routeWhileDragging: true
}).addTo(mymap);

    var popup = L.popup();

    function onMapClick(e) {
        popup
            .setLatLng(e.latlng)
            .setContent("You clicked the map at " + e.latlng.toString())
            .openOn(mymap);
    }

    mymap.on('click', onMapClick);
  • 1
    A routing engine doesn't work with raster tiles. These tiles are only for rendering. You need to update the database of the routing engine you are using. – scai May 22 '19 at 10:39
  • i see, is there a way to change the database of leaflet's routing machine with my own customized map? – DRAGONICX Zzzz May 23 '19 at 03:12
  • 1
    This depends on your setup. Leaflet Routing Machine supports various routing engines (OSRM, GraphHopper, Valhalla, ...). Which one are you using? Either way, you either need to upload your changes to the main OSM database (only if they are valid and if you didn't copy from incompatible sources) or install your own local routing engine. – scai May 23 '19 at 06:23
  • I understand, say i now have my own Graphhopper local routing engine, how am i able to connect it to leaflets routing machine – DRAGONICX Zzzz May 24 '19 at 02:55
  • ah, i did it, thanks so much for your help. it was so much simpler than i expected – DRAGONICX Zzzz May 24 '19 at 03:36
  • 1
    Great :) Can you add your solution as an answer? In case others run into the same problem. – scai May 24 '19 at 08:02

0 Answers0