Inspired by the great Arriving in Berlin map, Refugees Welcome to Norway wanted to create a similar map over Oslo.
And why not just open source it, so others can make use of it as well?
git clone git@github.com:engvik/rwtn-map.git
cd rwtn-map
npm install
npm start
Markers for the map, translations and available languages are configured by editing json files in config/
and locales/
.
This is the file for setting up the languages you support. Adding a language here, will make it an option on the front page.
[
{
"code": "en-US",
"name": "English"
},
{
"code": "nb-NO",
"name": "Norsk bokmål"
}
]
This will make English and Norwegian available on the site.
code
- The IETF language tag. Must correspond with the filename containing the translations in thelocales/
folder.name
- The name of the language as it will appear on the front page of the site.
Here are the markers for the map stored, along with the coordinates for the map view.
[
{
"start": [59.9212802, 10.7598769]
},
{
"type": "supermarket",
"icon": "",
"localeKey": "supermarket-1",
"coordinates": [59.9212802, 10.7598769]
},
{
"type": "doctor",
"icon": "",
"localeKey": "doctor-1",
"coordinates": [59.9200002, 10.7598769]
}
]
This will render the map with the coordinates 59.9212802, 10.7598769
and with two that map.
The first object in the array, has to be one defining the map view.
-
start
- The coordinates for the map view. Must be stored as a separate object, first on in the array. -
type
- What type of marker it is. This is used for filtering the map based on what type of marker it is. Remember to create a translation for the type. -
icon
- Used for defining what marker to render. -
localeKey
- The key for the translation in thelocales/
-folder. Will be rendered when you click the marker. -
coordinates
- The coordinates to place the marker.
This is where we store the translations files. The project comes with some predefined values for the static content on the site.
// en-US.json
[
{
"map-title": "Map",
"map-filter-type": "Filter",
}
]
// nb-NO.json
[
{
"map-title": "Kart",
"map-filter-type": "Filtrer",
}
]
As you can see, the same keys are used in both files. This makes it possible to retrieve the correct translation based on the language selected.
When you are defining markers, remember to create translations for each type you use. The key should be the same as the type.
If you have defined a marker like this:
{
"type": "doctor",
"icon": "",
"localeKey": "doctor-1",
"coordinates": [59.9200002, 10.7598769]
}
You should create a translation like this:
// en-US.json
{
"doctor": "Doctor"
}
// nb-NO.json
{
"doctor": "Lege"
}
If you want to see a bigger example with all of the configuration done, have a look at the map/oslo-branch to see the for Oslo.
PORT
NODE_ENV