Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Here V8 support #7

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["ie < 8"]
}
}]
]
}
78 changes: 41 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,55 @@ require('leaflet-routing-machine');
require('lrm-here'); // This will tack on the class to the L.Routing namespace

L.Routing.control({
router: new L.Routing.Here('your Here app id', 'your Here app code'),
router: new L.Routing.Here('your Here api key', {
routeRestriction: {
transportMode: 'truck'
},
truckRestriction: {
height: 300
},
urlParameters: {
avoid: {
tollTransponders: 'all'
}
}
}),
}).addTo(map);
```

Note that you will need to pass a valid Here app code and app id to the constructor.
Note that you will need to pass a valid Here apiKey to the constructor.


This is forked version based on [trailbehind](https://github.com/trailbehind/lrm-Here)
## Options
| Property | Type | Default | Options |
| ------------------------| ---------------------------- | -------------| ------- |
| alternatives | number | 0 | |
| noticesTypeAsRouteError | string['critical', 'info'] | ['critical'] | |
| routeRestriction | object<RouteRestriction> | | |
| truckRestriction | object<TruckRestriction> | | |
| urlParameters | object<any> | {} | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |

## RouteRestriction `routeRestriction`
Since the 1.1.0 version, you can calculate the route witch attributes of the route. To achieve this set `generateMode: true` and fill options under `routeRestriction` object using properties from below.

Since the 1.4.0 version, you can calculate the route with new attribute `trafficMode`.

| Property | Type | Default | Options |
| ------ | ----- | ------- | ------- |
| avoidHighways| boolean | | |
| avoidTolls | boolean | | |
| avoidFerries | boolean | | |
| trafficMode | boolean | false | |
| vehicleType | string | car | [Available options](https://developer.here.com/documentation/routing/topics/resource-param-type-routing-mode.html#type-transport-mode) |
| routeType | string | fastest | [Available options](https://developer.here.com/documentation/routing/topics/resource-param-type-routing-mode.html#type-routing-type) |

### WARNING
`generateMode` is by default `false` - Leaflet will calculate route using manually inserted mode (default `fastest;car;`)
| Property | Type | Default | Options |
| ------ | ----- | ------- | ------- |
| avoidHighways | boolean | false | |
| avoidTolls | boolean | false | |
| avoidFerries | boolean | false | |
| avoidDirtRoad | boolean | false | |
| trafficMode | boolean | false | |
| transportMode | string | car | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |
| routingMode | string | fast | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |

## TruckRestriction `truckRestriction`
Since the 1.2.0 version, you can calculate the route witch attributes of the truck. To achieve this set `routeRestriction.vehicleType: 'truck'` and fill options under `truckRestriction` object using properties from below.

Since the 1.3.1 version, you can calculate the route with new attribute `shippedHazardousGoods`.
| Property | Type | HumanType | Min | Max |
| ------ | ---- | --------- | --- | --- |
| height | int | centimeters | 0 | - |
| width | int | centimeters | 0 | - |
| length | int | centimeters | 0 | - |
| grossWeight | int | kilograms | 0 | - |
| weightPerAxle | int | kilograms | 0 | - |
| shippedHazardousGoods | array [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) | | | |
| trailerCount | int | count | 0 | 4 |

Since the 1.5.0 version, you can calculate the route with new attributes `enigneType` and `trailersCount`.

| Property | Type | HumanType | Min | Max |
| ------ | ---- | --------- | --- | --- |
| height | int | meters | 0 | 50 |
| width | int | meters | 0 | 50 |
| length | int | meters | 0 | 300 |
| limitedWeight | int | tons | 0 | 1000|
| weightPerAxle | int | tons | 0 | 1000|
| shippedHazardousGoods | array [Available options](https://developer.here.com/documentation/routing/topics/resource-type-enumerations.html#resource-type-enumerations__enum-hazardous-good-type-type) | | | |
| engineType | string [Available options](https://developer.here.com/documentation/routing/dev_guide/topics/resource-param-type-vehicle-type.html#type-engine-type) | | | |
| trailersCount | int | count | 0 | 4 |

### WARNING
Property will not be added if its value is empty (`''` or `null` or `[]`).

When TruckRestrictions are enabled, property `truckType`(read-only) will automatically added to request witch value `'truck'`.
This is forked version based on [trailbehind](https://github.com/trailbehind/lrm-Here)
9 changes: 5 additions & 4 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
<head>
<meta charset="utf-8" />
<title>Leaflet Here Example</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ==" crossorigin=""/>
<link rel="stylesheet" href="https://rawgit.com/perliedman/leaflet-routing-machine/master/dist/leaflet-routing-machine.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css" />
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div id="map" class="map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="https://rawgit.com/perliedman/leaflet-routing-machine/master/dist/leaflet-routing-machine.js"></script>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js" integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ==" crossorigin=""></script>
<script src="https://unpkg.com/innelo-leaflet-control-geocoder@2.4.3/dist/Control.Geocoder.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.js"></script>
<script src="../dist/lrm-here.js"></script>
<script src="Control.Geocoder.js"></script>
<script src="index.js"></script>
</body>
</html>
33 changes: 23 additions & 10 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
var map = L.map('map');
var map = L.map('map', {
zoom: 11,
center: [0, 0],
});

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap',
}).addTo(map);

L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
],
geocoder: L.Control.Geocoder.nominatim(),
router: L.Routing.here('here app id', 'here app code'),
routeWhileDragging: false
waypoints: [L.latLng(49.94652,18.85274), L.latLng(50.04746,18.69581)],
showAlternatives: true,
geocoder: new L.Control.Geocoder.HEREv2({
apiKey: 'here api key',
maxResults: 3,
lang: 'pl',
}),
router: L.Routing.here('here api key', {
routeRestriction: {
transportMode: 'truck'
},
urlParameters: {
alternatives: 3,
}
}),
routeWhileDragging: false,
}).addTo(map);
Loading