Services
The library provides API clients for Woosmap's location services. All services are available in both the main map.js bundle and the lightweight services.js bundle (no map rendering).
DirectionsService
Calculates routes between an origin and destination.
var service = new woosmap.map.DirectionsService();
service.route({
origin: {lat: 48.8566, lng: 2.3522},
destination: {lat: 45.764, lng: 4.8357},
travelMode: woosmap.map.TravelMode.DRIVING,
provideRouteAlternatives: true,
}, function(result, status) {
if (status === "OK") {
// result.routes[0].overview_path — decoded LatLng array
// result.routes[0].legs[0].distance / duration
}
});
Note
DirectionsService.route() uses a callback pattern, not Promises.
DistanceService
Distance matrix and isochrone calculations. Returns Promises.
var service = new woosmap.map.DistanceService();
// Distance matrix
service.getDistanceMatrix({
origins: [{lat: 48.8566, lng: 2.3522}],
destinations: [{lat: 45.764, lng: 4.8357}],
travelMode: woosmap.map.TravelMode.DRIVING,
unitSystem: woosmap.map.UnitSystem.METRIC,
}).then(function(response) {
// response.rows[0].elements[0].distance / duration
});
// Isochrone
service.getDistanceIsochrone({
origin: {lat: 48.8566, lng: 2.3522},
travelMode: woosmap.map.TravelMode.DRIVING,
value: 60, // minutes (max 120)
}).then(function(response) {
// response.isoline.path — LatLng array
});
StoresService
Search, autocomplete, and retrieve store data.
var service = new woosmap.map.StoresService();
// Search
service.search({
query: "type:gas_station",
latLng: {lat: 48.8566, lng: 2.3522},
radius: 5000,
}).then(function(response) { /* ... */ });
// Autocomplete
service.autocomplete({
query: "paris",
language: "fr",
limit: 5,
}).then(function(response) { /* ... */ });
// Get by ID
service.getStoreById("store_123").then(function(store) { /* ... */ });
LocalitiesService
Address autocomplete and geocoding.
var service = new woosmap.map.LocalitiesService();
DatasetsService
Query Woosmap datasets.
var service = new woosmap.map.DatasetsService();
TransitService
Public transit routing.
var service = new woosmap.map.TransitService();
Enums
TravelMode
| Value | API Parameter |
|---|---|
TravelMode.DRIVING |
"driving" |
TravelMode.WALKING |
"walking" |
TravelMode.BICYCLING |
"cycling" |
UnitSystem
| Value | API Parameter |
|---|---|
UnitSystem.METRIC |
"metric" |
UnitSystem.IMPERIAL |
"imperial" |
DistanceServiceStatus
| Value | Description |
|---|---|
OK |
Success |
INVALID_REQUEST |
Invalid parameters |
MAX_ELEMENTS_EXCEEDED |
More than 200 matrix elements |
MAX_ROUTE_LENGTH_EXCEEDED |
Route > 1000km or matrix/isochrone > 500km |
BACKEND_ERROR |
Server-side error |
REQUEST_DENIED |
Invalid API key or quota exceeded |
OVER_QUERY_LIMIT |
Rate limited |
Services-Only Bundle
For headless API usage without map rendering, load the services.js bundle:
<script src="https://sdk.woosmap.com/map/services.js?key=YOUR_API_KEY"></script>
<script>
var distance = new woosmap.map.DistanceService();
// All services available, no map rendering overhead
</script>
For full API details, see the generated Maps Reference and Indoor Reference.