Description
Goal: mapzen.js should make it easy for users to set a default language for all components.
Mapzen Basemaps, Search (geocoder), and Turn-by-turn (routing) all individually allow for language localization. However, these parameters are somewhat buried and not shared across components.
For example, to change the basemap, search, and routing directions to German, you must set a parameter in three different places:
// Add map
var map = L.Mapzen.map('map', {
tangramOptions: {
scene: {
import: L.Mapzen.BasemapStyles.Refill,
global: {
ux_language: 'de'
}
}
}
});
// Add search box
var geocoder = L.Mapzen.geocoder({
params: {
lang: 'de'
}
}).addTo(map);
// Add routing
var routingControl = L.Mapzen.routing.control({
waypoints: [
L.latLng(37.752, -122.418),
L.latLng(37.779, -122.391)
],
geocoder: L.Mapzen.routing.geocoder(),
reverseWaypoints: true,
router: L.Mapzen.routing.router({
directions_options: {
language: 'de'
}
})
}).addTo(map);
There are a few ways we could make this easier for the user:
-
Set up a global variable on L.Mapzen (e.g.,
L.Mapzen.language
) to be used by all components (similar to how we handle api keys) -
Set up an attribute on the
MapControl
object and pass to all components -
Improve documentation for changing the default language on all three components
Other things to consider:
- Are we planning to change the structure of Basemaps to handle the growing number of available parameters (language, transit, bike overlay, etc.)?
- (Especially if we do change the structure) This seems like a good candidate for v1.0 release.
@hanbyul-here thoughts?