Map settings¶
Info
For a complete list of available parameters, refer to the default values in geotrek/settings/base.py.
Leaflet configuration¶
Change or add tiled basemaps (IGN, OSM, Mapbox…)¶
By default, a Geotrek-admin installation includes two basemap layers: OpenStreetMap and OpenTopoMap.
You can customize or add more tiled basemap layers by specifying the tile URLs in your custom Django settings file:
LEAFLET_CONFIG['TILES'] = [('NAME_OF_TILE', 'URL', 'COPYRIGHT'), ...]
Note
Geotrek-admin (via Leaflet) only supports basemaps served as tiles in the {z}/{x}/{y} format. This means that standard WMS services are not supported.
Only WMTS services or other XYZ tile providers (like OpenStreetMap, OpenTopoMap, Mapbox, etc.) can be used. WMTS is a standard protocol that can provide such tiles, but not all XYZ tile providers follow WMTS – for example, OpenStreetMap does not.
If you plan to use IGN Geoportail WMTS layers (such as Plan IGN, Scan25, Orthophotos…), an API key might be required. For more details, see https://geoservices.ign.fr/services-geoplateforme-diffusion.
LEAFLET_CONFIG['TILES'] = [
(
'OpenTopoMap',
'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
{
'attribution': 'map data: © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>; contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>;)',
'maxNativeZoom': 17,
'maxZoom': 22
}
),
(
'OpenStreetMap',
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
'attribution': '© <a href="https://www.openstreetmap.org/copyright">Contributeurs d\'OpenStreetMap</a>',
'maxNativeZoom': 19,
'maxZoom': 22
}
)
]
LEAFLET_CONFIG['TILES'] = [
(
'IGN Plan V2',
'//data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&STYLE=normal&FORMAT=image/png&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
{
'attribution': 'Plan IGNV2 - Carte © IGN/Geoportail',
'maxNativeZoom': 16,
'maxZoom': 22
}
),
(
'IGN Orthophotos',
'//data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&FORMAT=image/jpeg&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
{
'attribution': 'Orthophotos - Carte © IGN/Geoportail',
'maxNativeZoom': 19,
'maxZoom': 22
}
),
(
'OpenStreetMap',
'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
'attribution': '© <a href="https://www.openstreetmap.org/copyright">Contributeurs d\'OpenStreetMap</a>',
'maxNativeZoom': 19,
'maxZoom': 22
}
),
(
'OpenTopoMap',
'//{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
{
'attribution': 'map data: © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)',
'maxNativeZoom': 17,
'maxZoom': 22
}
),
(
'IGN Scan 25',
'//data.geopf.fr/private/wmts?apikey=ign_scan_ws&LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
{
'attribution': 'Plan Scan 25 Touristique - Carte © IGN/Geoportail',
'maxNativeZoom': 17,
'maxZoom': 22
}
),
]
Map overlays¶
Note
- It is possible to add overlay tiles layer on maps. For example, it can be useful to:
Display the cadastral parcels on top of satellite images
Display home made layers (with Tilemill or QGisMapserver for example).
Display the park center borders, traffic maps, IGN BDTopo® or even the Geotrek paths that are marked as invisible in the database!
You can configure overlays layers like this:
LEAFLET_CONFIG['OVERLAYS'] = [
(
'IGN Cadastre',
'//data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=CADASTRALPARCELS.PARCELLAIRE_EXPRESS&STYLE=normal&FORMAT=image/png&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
{
'attribution': 'Cadastre - Carte © IGN/Geoportail',
'maxNativeZoom': 19,
'maxZoom': 22
}
),
]
LEAFLET_CONFIG['OVERLAYS'] = [
('Coeur de parc', 'http://serveur/coeur-parc/{z}/{x}/{y}.png', '© PNF'),
]
Expected properties:
For GeoJSON files, you can provide the following properties :
title: stringdescription: stringwebsite: stringphone: stringpictures: list of objects withurlandcopyrightattributescategory: object withidandlabelattributes
Map layers zoom¶
You can define the max_zoom the user can zoom for all tiles.
LEAFLET_CONFIG['MAX_ZOOM'] = 19
LEAFLET_CONFIG['MAX_ZOOM'] = 20
Note
It can be interesting when your tiles can’t go to a zoom. For example OpenTopoMap is 17.
Mapentity configuration¶
Map layers colors and style¶
All layers colors can be customized from the settings. See Leaflet reference for vectorial layer style.
See the default values in geotrek/settings/base.py for the complete list of available styles.
MAPENTITY_CONFIG['MAP_STYLES'] = {
# Path
'path': {'weight': 2, 'color': '#FF4800', 'opacity': 1.0},
# Draft path
'draftpath': {'weight': 5, 'opacity': 1, 'color': 'yellow', 'dashArray': '8, 8'},
# City
'city': {'weight': 4, 'color': '#FF9700', 'opacity': 0.3, 'fillOpacity': 0.0},
# District
'district': {'weight': 6, 'color': '#FF9700', 'opacity': 0.3, 'fillOpacity': 0.0, 'dashArray': '12, 12'},
# Restricted area
'restrictedarea': {'weight': 2, 'color': 'red', 'opacity': 0.5, 'fillOpacity': 0.5},
# Land edge
'land': {'weight': 4, 'color': 'red', 'opacity': 1.0},
# Physical edge
'physical': {'weight': 6, 'color': 'red', 'opacity': 1.0},
# Circulation edge
'circulation': {'weight': 6, 'color': 'red', 'opacity': 1.0},
# Competence edge
'competence': {'weight': 4, 'color': 'red', 'opacity': 1.0},
# Work management edge
'workmanagement': {'weight': 4, 'color': 'red', 'opacity': 1.0},
# Signage management edge
'signagemanagement': {'weight': 5, 'color': 'red', 'opacity': 1.0},
# File imported via FileLayer (e.g., GPX, KML, GeoJSON)
'filelayer': {'color': 'blue', 'opacity': 1.0, 'fillOpacity': 0.9, 'weight': 3, 'radius': 5},
# Object detail (used to focus on a specific feature)
'detail': {'color': '#ffff00'},
# Other objects
'others': {'color': '#ffff00'},
# Styles used for PDF printing
'print': {
# Path
'path': {'weight': 1},
# Trek
'trek': {
'color': '#FF3300', 'weight': 7, 'opacity': 0.5,
'arrowColor': 'black', 'arrowSize': 10
},
}
}
Example to override configuration for displaying Path objects:
MAPENTITY_CONFIG['MAP_STYLES']['path'] = {'color': 'red', 'weight': 5}
Example to override a specific parameter:
MAPENTITY_CONFIG['MAP_STYLES']['city']['opacity'] = 0.8
Example to override color, thickness, and opacity displayed in the PDF printout:
MAPENTITY_CONFIG['MAP_STYLES'] = {
'print': {
'path': {'weight': 1},
'trek': {'color': 'blue', 'weight': 10, 'opacity': 0.5, 'arrowSize': 10},
}
}
Colors pool¶
Regarding colors that depend from database content, such as land layers (physical types, work management…) or restricted areas. We use a specific setting that receives a list of colors:
See the default values in geotrek/settings/base.py for the complete list of colors.
COLORS_POOL = {
'land': ['#f37e79', '#7998f3', '#bbf379', '#f379df', '#f3bf79', '#9c79f3', '#7af379'],
'physical': ['#f3799d', '#79c1f3', '#e4f379', '#de79f3', '#79f3ba', '#f39779', '#797ff3'],
'circulation': ['#f3799d', '#79c1f3', '#e4f379', '#de79f3', '#79f3ba', '#f39779', '#797ff3'],
'competence': ['#a2f379', '#f379c6', '#79e9f3', '#f3d979', '#b579f3', '#79f392', '#f37984'],
'signagemanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
'workmanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
'restrictedarea': ['plum', 'violet', 'deeppink', 'orchid',
'darkviolet', 'lightcoral', 'palevioletred',
'MediumVioletRed', 'MediumOrchid', 'Magenta',
'LightSalmon', 'HotPink', 'Fuchsia']}
COLORS_POOL['restrictedarea'] = ['#ff00ff', 'red', '#ddddd'...]
Note
Each of the object types for Status module (
land,physical,competence,signagemanagement,workmanagement…) should have values defined.For
restrictedarea: add as many color there are restricted area types
Disable darker map backgrounds¶
Since IGN map backgrounds are very dense and colourful, a dark opacity is applied. In order to disable, change this MapEntity setting:
MAPENTITY_CONFIG['MAP_BACKGROUND_FOGGED'] = True
MAPENTITY_CONFIG['MAP_BACKGROUND_FOGGED'] = False
Popup configuration¶
Geotrek displays a popup when clicking on an object on the map. By default, this popup shows the object’s name, its type, and a button linking to its detail page.
You can customize the fields displayed in the popup for each model by defining the POPUP_CONTENT setting in /var/conf/custom.py:
POPUP_CONTENT = {
"signage": ["code", "type", "conditions"],
}
Each key corresponds to a model name written in lowercase (for example, "signage"),
and each value is a list of field names to display in the popup.
The available fields are the same as those that can be configured for column display and exports. For more information, see Custom columns available.
Map screenshots¶
When you generate a PDF in Geotrek-admin, a screenshot of the map with the object location is done. This section list all the available parameters to configure this screenshot. Therefore, if you change one of those values, pdfs will be rendered differently.
Note
For all these settings, we recommand you to check the result every time. Be careful, map screenshots are stored in cache so you need to force the re-generation of the computed images. To do so, you need to update the geometry of an object and save it, it will re-create image and help check your configuration.
After validation of your modifications, to force Geotrek to re-create all the screenshots, you need to delete cached files in the folder /opt/geotrek-admin/var/media/maps.
cd /opt/geotrek-admin/var/media/maps
rm *
Display related objects¶
Include objects in map screenshots:
SHOW_SENSITIVE_AREAS_ON_MAP_SCREENSHOT = True
SHOW_POIS_ON_MAP_SCREENSHOT = True
SHOW_SERVICES_ON_MAP_SCREENSHOT = True
SHOW_SIGNAGES_ON_MAP_SCREENSHOT = True
SHOW_INFRASTRUCTURES_ON_MAP_SCREENSHOT = True
SHOW_SENSITIVE_AREAS_ON_MAP_SCREENSHOT = True
SHOW_POIS_ON_MAP_SCREENSHOT = False
SHOW_SERVICES_ON_MAP_SCREENSHOT = True
SHOW_SIGNAGES_ON_MAP_SCREENSHOT = False
SHOW_INFRASTRUCTURES_ON_MAP_SCREENSHOT = False
Map capture size¶
MAP_CAPTURE_SIZE = 800
Geographical CRUD¶
Path snapping distance¶
🗺️ Data stored via dynamic segmentation when enabled
Minimum distance to merge two paths in unit of SRID.
PATH_SNAPPING_DISTANCE = 1 # Distance of path snapping in meters
PATH_SNAPPING_DISTANCE = 2
Note
Used only when TREKKING_TOPOLOGY_ENABLED = True
Snap distance¶
Distance of snapping for the cursor in pixels on Leaflet map.
SNAP_DISTANCE = 30 # Distance of snapping in pixels
SNAP_DISTANCE = 15
Path merge snapping distance¶
Minimum distance to merge two paths.
PATH_MERGE_SNAPPING_DISTANCE = 2 # minimum distance to merge paths
PATH_MERGE_SNAPPING_DISTANCE = 3
Note
Should be higher or the same as
PATH_SNAPPING_DISTANCE.Used only when
TREKKING_TOPOLOGY_ENABLED = True.
Enable treks points of reference¶
Points of reference can be enabled in the forms for treks.
TREK_POINTS_OF_REFERENCE_ENABLED = True
TREK_POINTS_OF_REFERENCE_ENABLED = False
Enable outdoor course points of reference¶
Points of reference can be enabled in the forms for outdoor courses.
OUTDOOR_COURSE_POINTS_OF_REFERENCE_ENABLED = True
OUTDOOR_COURSE_POINTS_OF_REFERENCE_ENABLED = False
Enable HD views¶
Enable or disable high-definition views in the interface:
ENABLE_HD_VIEWS = True
ENABLE_HD_VIEWS = False
Topology static offset¶
Land objects are added on other objects (path for example) with offset, avoiding overlay.
TOPOLOGY_STATIC_OFFSETS = {'land': -5,
'physical': 0,
'circulation': 15,
'competence': 5,
'signagemanagement': -10,
'workmanagement': 10}
TOPOLOGY_STATIC_OFFSETS = {'land': -5,
'physical': 0,
'competence': 5,
'signagemanagement': -10,
'workmanagement': 10}
Profil altimétrique¶
ALTIMETRIC_PROFILE_PRECISION = 25 # Sampling precision in meters
ALTIMETRIC_PROFILE_AVERAGE = 2 # nb of points for altimetry moving average
ALTIMETRIC_PROFILE_STEP = 1 # Step min precision for positive / negative altimetry gain
ALTIMETRIC_PROFILE_BACKGROUND = 'white'
ALTIMETRIC_PROFILE_COLOR = '#F77E00'
ALTIMETRIC_PROFILE_HEIGHT = 400
ALTIMETRIC_PROFILE_WIDTH = 800
ALTIMETRIC_PROFILE_FONTSIZE = 25
ALTIMETRIC_PROFILE_FONT = 'ubuntu'
ALTIMETRIC_PROFILE_MIN_YSCALE = 1200 # Minimum y scale (in meters)
ALTIMETRIC_AREA_MAX_RESOLUTION = 150 # Maximum number of points (by width/height)
ALTIMETRIC_AREA_MARGIN = 0.15
ALTIMETRIC_PROFILE_PRECISION = 30
ALTIMETRIC_PROFILE_AVERAGE = 4 # nb of points for altimetry moving average
ALTIMETRIC_PROFILE_STEP = 1 # Step min precision for positive / negative altimetry gain
ALTIMETRIC_PROFILE_BACKGROUND = 'white'
ALTIMETRIC_PROFILE_COLOR = '#F77E00'
ALTIMETRIC_PROFILE_HEIGHT = 500
ALTIMETRIC_PROFILE_WIDTH = 1000
ALTIMETRIC_PROFILE_FONTSIZE = 30
ALTIMETRIC_PROFILE_FONT = 'ubuntu'
ALTIMETRIC_PROFILE_MIN_YSCALE = 1200 # Minimum y scale (in meters)
ALTIMETRIC_AREA_MAX_RESOLUTION = 150 # Maximum number of points (by width/height)
ALTIMETRIC_AREA_MARGIN = 0.30
Note
For all these settings, we recommand you to check the result every time. Be careful, altimetric profiles are stored in cache so you need to force the re-generation of the computed images. To do so, you need to update the geometry of an object and save it, it will re-create image and help check your configuration.
After validation of your modifications, to force Geotrek to re-create all the altimetric profiles, you need to delete cached files in the folder /opt/geotrek-admin/var/media/profiles.
cd /opt/geotrek-admin/var/media/profiles
rm *
Routing¶
pgRouting’s tolerance¶
Snapping tolerance of disconnected edges/coincident points (in projection unit).
PGROUTING_TOLERANCE = 0.001
PGROUTING_TOLERANCE = 0.01
Avertissement
After modifying this parameter, you must regenerate pgRouting’s network topology for the change to take effect.
Use the generate_pgr_network_topology command with the --flush option. Refer to this section to learn about this command.
Note
For more information, consult pgRouting’s documentation: https://docs.pgrouting.org/latest/en/index.html