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

Adding sample layer #41

Closed
mir123 opened this issue Mar 13, 2019 · 2 comments
Closed

Adding sample layer #41

mir123 opened this issue Mar 13, 2019 · 2 comments

Comments

@mir123
Copy link

mir123 commented Mar 13, 2019

I would like to customize the list of sample base layers for a group of students. I have added TopoJSON and GeoJSON files to magrit_app/static/data_sample, and modified static/json/sample_layers.json and client/js/layers.js and can't make it work.

@mthh
Copy link
Member

mthh commented Mar 13, 2019

Thanks for the report !

Sorry, this part of the code is not very clear (in the end there remains a place to modify in the code in the layers.js source file so that these layers are added in the interface): you have to reference theses layers in the target_layers variable :

magrit/client/js/layers.js

Lines 129 to 167 in 5f15596

const target_layers = [
[_tr('app_page.sample_layer_box.layer'), ''],
[_tr('app_page.sample_layer_box.grandparismunicipalities'), 'GrandParisMunicipalities'],
[_tr('app_page.sample_layer_box.quartier_paris'), 'quartier_paris'],
[_tr('app_page.sample_layer_box.martinique'), 'martinique'],
[_tr('app_page.sample_layer_box.departements_2016_2-2'), 'departements_2016_2-2'],
[_tr('app_page.layout_layer_box.departements_vor_2016_2-2'), 'departements_vor_2016_2-2'],
[_tr('app_page.sample_layer_box.regions_2016_2-2'), 'regions_2016_2-2'],
[_tr('app_page.layout_layer_box.france_contour_2016_2-2'), 'france_contour_2016_2-2'],
[_tr('app_page.sample_layer_box.nuts2_data'), 'nuts2-2013-data'],
[_tr('app_page.sample_layer_box.brazil'), 'brazil'],
[_tr('app_page.sample_layer_box.world_countries'), 'world_countries_data'],
[_tr('app_page.sample_layer_box.communes_reg_11'), 'communes_reg_11'],
[_tr('app_page.sample_layer_box.communes_reg_24'), 'communes_reg_24'],
[_tr('app_page.sample_layer_box.communes_reg_27'), 'communes_reg_27'],
[_tr('app_page.sample_layer_box.communes_reg_28'), 'communes_reg_28'],
[_tr('app_page.sample_layer_box.communes_reg_32'), 'communes_reg_32'],
[_tr('app_page.sample_layer_box.communes_reg_44'), 'communes_reg_44'],
[_tr('app_page.sample_layer_box.communes_reg_52'), 'communes_reg_52'],
[_tr('app_page.sample_layer_box.communes_reg_53'), 'communes_reg_53'],
[_tr('app_page.sample_layer_box.communes_reg_75'), 'communes_reg_75'],
[_tr('app_page.sample_layer_box.communes_reg_76'), 'communes_reg_76'],
[_tr('app_page.sample_layer_box.communes_reg_84'), 'communes_reg_84'],
[_tr('app_page.sample_layer_box.communes_reg_93'), 'communes_reg_93'],
[_tr('app_page.sample_layer_box.communes_reg_94'), 'communes_reg_94'],
[_tr('app_page.sample_layer_box.commune_dep_971'), 'commune_dep_971'],
[_tr('app_page.sample_layer_box.commune_dep_972'), 'commune_dep_972'],
[_tr('app_page.sample_layer_box.commune_dep_973'), 'commune_dep_973'],
[_tr('app_page.sample_layer_box.commune_dep_974'), 'commune_dep_974'],
[_tr('app_page.sample_layer_box.commune_dep_976'), 'commune_dep_976'],
[_tr('app_page.sample_layer_box.voronoi_communes_2016_2-2'), 'voronoi_communes_2016_2-2'],
[_tr('app_page.layout_layer_box.nuts0'), 'nuts0'],
[_tr('app_page.layout_layer_box.nuts1'), 'nuts1'],
[_tr('app_page.layout_layer_box.nuts2'), 'nuts2'],
[_tr('app_page.sample_layer_box.world_countries'), 'world_countries_data'],
[_tr('app_page.layout_layer_box.world_countries'), 'world_country'],
[_tr('app_page.layout_layer_box.world_capitals'), 'world_cities'],
[_tr('app_page.layout_layer_box.tissot'), 'tissot'],
];

and recompile the JS code with webpack following the instructions (in CONTRIBUTING.md).

If you want your new sample layers to be opened with a particular projection, you can specify it in the suggested_projection variable in the same file:

const suggested_projection = new Map([

Finally, if you want the type of each field to be "hardcoded" for theses samples layers, you can define them in the fields_type_sample variable in the same file :

const fields_type_sample = new Map([

Note that you don't have to add both geojson and topojson format for the same layer, just one of them (the one referenced in sample_layers.json) is enough.

Don't hesitate if you're still facing issues with theses examples layers.

@mthh
Copy link
Member

mthh commented Apr 24, 2019

Fixed by #45.

@mthh mthh closed this as completed Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants