Javascript examples for Leaflet:Map
add Leaflet Routing Machine control outside the map div
<html> <head> <title>Route controls outside map</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"> <link rel="stylesheet" type="text/css" href="http://www.liedman.net/leaflet-routing-machine/dist/leaflet-routing-machine.css"> <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> <script type="text/javascript" src="http://www.liedman.net/leaflet-routing-machine/dist/leaflet-routing-machine.js"></script> <script type="text/javascript" src="http://www.liedman.net/leaflet-routing-machine/lib/Control.Geocoder.js"></script> <style id="compiled-css" type="text/css"> #map {// ww w. j a va2 s .c o m height: 300px; margin-top: 20px; } </style> </head> <body> <div id="map"></div> <div id="controls"></div> <script type="text/javascript"> var map = L.map('map').setView([32.78250, -96.79750], 14); //52.28150, 8.92567 //32.78250, -96.79750 L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors. ' + 'Routes from <a href="http://project-osrm.org/">OSRM</a>, ' + 'data uses <a href="http://opendatacommons.org/licenses/odbl/">ODbL</a> license' }).addTo(map); var control = L.Routing.control({ waypoints: [ L.latLng(32.78186, -96.76612), L.latLng(32.77602, -96.80766) ], geocoder: L.Control.Geocoder.nominatim(), routeWhileDragging: true, reverseWaypoints: true, fitSelectedRoutes: true }); var routeBlock = control.onAdd(map); document.getElementById('controls').appendChild(routeBlock); </script> </body> </html>