Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann Levesque authored and Johann Levesque committed Jun 17, 2024
1 parent eb3db9c commit 237acdf
Show file tree
Hide file tree
Showing 36 changed files with 719 additions and 332 deletions.
97 changes: 97 additions & 0 deletions add-layers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Canadian Geospatial Platform Viewer</title><link rel="shortcut icon" href="./favicon.ico"/><meta name="msapplication-TileColor" content="#da532c"/><meta name="msapplication-config" content="./img/browserconfig.xml"/><meta name="theme-color" content="#ffffff"/><meta name="msapplication-TileColor" content="#da532c"/><meta name="theme-color" content="#ffffff"/><link rel="stylesheet" href="css/style.css"/><style>li.source-link {
cursor: pointer;
color: #6082b6;
}

.sourceLinkCopied {
position: fixed;
top: 6px;
right: 6px;
background-color: darkblue;
color: white;
padding: 16px;
font-size: 16px;
min-width: 150px;
text-align: center;
border-radius: 5px;
z-index: 1;
}</style><script src="cgpv-main.js"></script></head><body><div class="header-table"><table><tbody><tr><td><img class="header-logo" alt="logo" src="./img/Logo.png"/></td><td class="header-title"><h1><strong>Package - Layers Panel</strong></h1></td></tr><tr><td><a href="./index.html">Main</a><br/><a href="#HUC1">Default Configuration</a><br/></td></tr></tbody></table><table><tbody><tr><td>This page is used to showcase loading "Layers Panel" with the ability to add various layer types.</td></tr></tbody></table></div><div class="map-title-holder"><h4 id="HUC1">1. Default Configuration</h4><a class="ref-link" href="#top">Top</a></div><select name="projections" id="projections"><option value="3857">Web Mercator (3857)</option><option value="3978">LCC (3978)</option></select> <button type="button" onclick="reloadMap()">Set Projection</button><div id="mapWM" class="geoview-map" data-lang="en" data-config="{
'map': {
'interaction': 'dynamic',
'viewSettings': {
'projection': 3857
},
'basemapOptions': {
'basemapId': 'transport',
'shaded': true,
'labeled': true
},
'listOfGeoviewLayerConfig': []
},
'theme': 'geo.ca',
'components': [],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table', 'geochart', 'time-slider']
}
},
'corePackages': [],
'externalPackages': [],
'appBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table', 'geochart']
}
}
}"></div><h4>Add Layer Examples</h4><div style="font-size: smaller"><div>ESRI Feature Service Layer<ul><li class="source-link">https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/forest_industry_hotspots_en/MapServer/0</li></ul></div><div>ESRI Dynamic Service Layer<ul><li class="source-link">https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/historical_flood_event_en/MapServer</li><li class="source-link">https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/forest_industry_hotspots_en/MapServer</li></ul></div><div>ESRI Image Layer<ul><li class="source-link">https://www5.agr.gc.ca/atlas/rest/services/app_agclimate_agclimat/agclimate_tx/ImageServer/</li></ul></div><div>WMS Layer<ul><li class="source-link">https://ows.mundialis.de/services/service</li><li>https://datacube.services.geo.ca/ows/msi?request=GetCapabilities&service=wms&version=1.3.0&layers=msi</li></ul></div><div>WFS Layer<ul><li class="source-link">https://ahocevar.com/geoserver/wfs?REQUEST=GetCapabilities&VERSION=2.0.0&SERVICE=WFS</li></ul></div><div>XYZ Layer<ul><li class="source-link">https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}</li></ul></div><div>GeoJson Layer<ul><li class="source-link">https://canadian-geospatial-platform.github.io/geoview/public/datasets/geojson/polygons.json</li><li class="source-link">https://canadian-geospatial-platform.github.io/geoview/public/datasets/geojson/lines.json</li><li class="source-link">https://canadian-geospatial-platform.github.io/geoview/public/datasets/geojson/points.json</li></ul></div><div>OGC API Feature Layer<ul><li class="source-link">https://b6ryuvakk5.execute-api.us-east-1.amazonaws.com/dev</li><li class="source-link">https://b6ryuvakk5.execute-api.us-east-1.amazonaws.com/dev/collections/lakes</li></ul></div><div>GeoPackage Layer<ul><li class="source-link">https://canadian-geospatial-platform.github.io/geoview/public/datasets/geopackages/rivers.gpkg</li></ul></div><div>CSV Layer<ul><li class="source-link">https://canadian-geospatial-platform.github.io/geoview/public/datasets/csv-files/Station_List_Minus_HQ-MELCC.csv</li></ul></div><div style="margin-bottom: 20px"><div>GeoCore UUID Layer</div><div style="margin-top: 10px; margin-left: 20px"><input id="selectGeoCore" list="geocoreids" style="width: 300px"/><datalist id="geocoreids"><option value="21b821cf-0f1c-40ee-8925-eab12d357668"></option><option value="ccc75c12-5acc-4a6a-959f-ef6f621147b9"></option><option value="0fca08b5-e9d0-414b-a3c4-092ff9c5e326"></option><option value="03ccfb5c-a06e-43e3-80fd-09d4f8f69703"></option><option value="ea4c0bdb-a63f-49a4-b14a-09c1560aad0b"></option><option value="0fe65119-e96e-4a57-8bfe-9d9245fba06b"></option><option value="ed9b204b-590c-4b17-9703-f6e167acd6c6"></option></datalist><button type="button" onclick="addGeocore()">Add layer</button></div></div><hr/><button type="button" class="collapsible">Configuration Snippet</button><pre id="mapWMCS" class="panel"></pre><hr/><script src="codedoc.js"></script><script>function addGeocore() {
// Precond
if (!document.getElementById('selectGeoCore').value) return;

// Add the layer on the map
cgpv.api.maps['mapWM'].layer.addGeoviewLayerByGeoCoreUUID(document.getElementById('selectGeoCore').value);
}

document.addEventListener('DOMContentLoaded', function () {
var sourceLinks = document.querySelectorAll('li.source-link');

sourceLinks.forEach(function (link) {
link.addEventListener('click', function () {
// Get the content to copy
var contentToCopy = link.innerHTML;

// Create a temporary textarea element to copy the content
var textarea = document.createElement('textarea');
textarea.value = contentToCopy;
document.body.appendChild(textarea);

// Select the content and copy it to the clipboard
textarea.select();
document.execCommand('copy');

// Remove the temporary textarea
document.body.removeChild(textarea);

// Show a message for 5 seconds
var message = document.createElement('div');
message.classList.add('sourceLinkCopied');
message.innerHTML = 'Copied to clipboard';
document.body.appendChild(message);
setTimeout(function () {
// Remove the message after 5 seconds
document.body.removeChild(message);
}, 2000);
});
});
});</script><script>function reloadMap() {
cgpv.api.maps['mapWM'].setProjection(Number(document.getElementById('projections').value));
}

// initialize cgpv and api events, a callback is optional, used if calling api's after the rendering is ready
cgpv.init((mapId) => {
// write some code ...
});

// create snippets
window.addEventListener('load', () => {
createCodeSnippet();
createConfigSnippet();
});</script></div></body></html>
68 changes: 34 additions & 34 deletions cgpv-main.js

Large diffs are not rendered by default.

Binary file modified cgpv-main.js.br
Binary file not shown.
2 changes: 1 addition & 1 deletion cgpv-main.js.map

Large diffs are not rendered by default.

45 changes: 31 additions & 14 deletions config-sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
white-space: nowrap;
}</style><script src="cgpv-main.js"></script></head><body><div class="header-table"><table><tbody><tr><td><img class="header-logo" alt="logo" src="./img/Logo.png"/></td><td class="header-title"><h1><strong>Sandbox Configuration</strong></h1></td></tr></tbody></table><table><tbody><tr><td><a href="./index.html">Main</a><br/></td></tr></tbody></table><table><tbody><tr><td>This page is used to test map configuration.</td></tr></tbody></table><table><tbody><tr><td><span>Input Configuration</span><div class="editor"><div class="line-numbers" id="inputLineNumbers"><span></span></div><textarea id="configGeoview" name="configuration" cols="110">
</textarea></div></td><td><span>Internal configuration:</span> <span id="validationMessage">File not validated...</span><div class="editor"><div class="line-numbers" id="outputLineNumbers"><span></span></div><textarea id="configOutput" name="configuration" cols="110">
</textarea></div></td></tr></tbody></table></div><div><div class="selector-container"><p>This section lets you select and edit a complete map configuration.<br/>The validate button calls the <b>ConfigApi.getMapConfig</b> method and displays the internal map configuration.</p><div class="selector">Configuration to load: <select name="Config Loader" id="configLoader"><option value="">--select--</option><option value="./configs/validator/01-simple.json">Simple</option><option value="./configs/validator/02-unique-value.json">Unique Value</option><option value="./configs/validator/03-class-breaks.json">Class Breaks</option><option value="./configs/validator/04-geocore.json">Geocore</option></select></div></div><button id="validateConfig" style="margin-top:10px;">Validate</button> <select id="language"><option value="en">English</option><option value="fr">Français</option></select> <button id="createMap" style="margin:10px;">Create Map</button> <button id="deleteMap" style="margin:10px;">Delete map</button></div><hr/><div class="selector"><p>This section lets you select and edit a GeoView service URL or a GeoCore identifier.<br/>The validate button calls the <b>ConfigApi.getLayerConfig</b> method and displays the resulting internal map configuration.</p>Service URL: <select name="Service Config" id="serviceConfig"><option value="">--select--</option><option value="esriDynamic">EsriDynamic</option><option value="esriFeature">EsriFeature</option><option value="geoCore">GeoCore</option></select></div><br/><div class="editor" style="height:20px"><div class="line-numbers" id="inputLineNumbers"><span></span></div><div><textarea id="serviceUrlGeoview" name="ServiceUrlconfiguration" cols="210">
</textarea></div></td></tr></tbody></table></div><div><div class="selector-container"><p>This section lets you select and edit a complete map configuration.<br/>The validate button calls the <b>ConfigApi.createMapConfig</b> method and displays the internal map configuration.</p><div class="selector">Configuration to load: <select name="Config Loader" id="configLoader"><option value="">--select--</option><option value="./configs/validator/01-simple.json">Simple</option><option value="./configs/validator/02-unique-value.json">Unique Value</option><option value="./configs/validator/03-class-breaks.json">Class Breaks</option><option value="./configs/validator/04-geocore.json">Geocore</option></select></div></div><button id="validateConfig" style="margin-top:10px;">Validate</button> <select id="language"><option value="en">English</option><option value="fr">Français</option></select> <button id="createMap" style="margin:10px;">Create Map</button> <button id="deleteMap" style="margin:10px;">Delete map</button></div><hr/><div class="selector"><p>This section lets you select and edit a GeoView service URL or a GeoCore identifier.<br/>The validate button calls the <b>ConfigApi.createLayerConfig</b> method and displays the resulting internal map configuration.</p>Service URL: <select name="Service Config" id="serviceConfig"><option value="">--select--</option><option value="esriDynamic">EsriDynamic</option><option value="esriFeature">EsriFeature</option><option value="geoCore">GeoCore</option></select></div><br/><div class="editor" style="height:20px"><div class="line-numbers" id="inputLineNumbers"><span></span></div><div><textarea id="serviceUrlGeoview" name="ServiceUrlconfiguration" cols="210">
</textarea></div></div><div><button id="validateServiceUrlConfig" style="margin-top:10px;">Validate</button><br/></div><hr/><p>This section allows you to enter a string of parameters that would be written at the end of a GeoView URL.<br/>The validation button calls the <b>ConfigApi.getConfigFromUrl</b> method and displays the resulting internal map configuration.</p><span>Parameters following the service URL:</span><br/><div class="editor" style="height:20px"><div class="line-numbers" id="inputLineNumbers"><span></span></div><div><textarea id="configUrlGeoview" name="Urlconfiguration" cols="210">
p=3857&z=4&c=-100,40&l=en&t=dark&b=basemapId:transport,shaded:false,labeled:true&i=dynamic&cc=overview-map&keys=12acd145-626a-49eb-b850-0a59c9bc7506,ccc75c12-5acc-4a6a-959f-ef6f621147b9
</textarea></div></div><div><button id="validateUrlConfig" style="margin-top:10px;">Validate</button><br/></div><hr/><div class="map-title-holder"><h4 id="HLCONF1">Sanbox Map</h4><a class="ref-link" href="#top">Top</a></div><div id="mapSection"><div id="sandboxMap"></div></div><p>This map loads it's configurations from the text area.</p><hr/><button type="button" class="collapsible">Code Snippet</button><pre id="codeSnippet" class="panel"></pre><script src="codedoc.js"></script><script>const configUrlArea = document.getElementById('configUrlGeoview');
Expand Down Expand Up @@ -94,17 +94,27 @@
const configOutput = document.getElementById('configOutput');

// get config and test if JSON is valid
cgpv.api.configApi.getMapConfig(configArea.value.replaceAll('"', "'").replaceAll("\\'", "\'"), langue).then((mapConfig) => {
configOutput.value = mapConfig.getIndentedJsonString();
cgpv.api.configApi.createMapConfig(configArea.value.replaceAll('"', "'").replaceAll("\\'", "\'"), langue).then((mapConfig) => {
configOutput.value = mapConfig.serialize();

generateLineNumbers('configOutput', 'outputLineNumbers');

// set class and message
message.classList.add('config-json-valid');
message.classList.remove('config-error');
if (mapConfig.isValid) {
message.innerHTML = 'File is valid, see console for details...';
document.getElementById('createMap').disabled = true;
if (!mapConfig.errorDetected) {
message.innerHTML = 'Config is valid, waiting for all service metadata to be read...';

// TODO: Change the code below using the schema provided during our last meating. This change must be done in the next PR
// Start reading the metadata
mapConfig.fetchAllServiceMetadata().then(() => {
configOutput.value = mapConfig?.serialize();
generateLineNumbers('configOutput', 'outputLineNumbers');
message.innerHTML = 'Config is valid, reading of all service metadata is complete';
document.getElementById('createMap').disabled = true;
}).catch((error) => {
throw new Error('Error while reading metadata.');
});
} else {
message.innerHTML = 'File is invalid, see console for details...';
}
Expand All @@ -115,7 +125,7 @@

const serviceUrlChoices = {
geoCore: '12acd145-626a-49eb-b850-0a59c9bc7506',
esriDynamic: 'https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/Temporal_Test_Bed_en/MapServer/',
esriDynamic: 'https://maps-cartes.ec.gc.ca/arcgis/rest/services/CESI/MapServer/',
esriFeature: 'https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/Temporal_Test_Bed_en/MapServer/',
};

Expand All @@ -139,18 +149,25 @@

configArea.value = serviceUrlArea.value;
// get config and test if URL Config is valid
const returnedValue = cgpv.api.configApi.getLayerConfig(serviceUrlArea.value.trim(), document.getElementById('serviceConfig').value);
const returnedValue = cgpv.api.configApi.createLayerConfig(serviceUrlArea.value.trim(), document.getElementById('serviceConfig').value);
returnedValue.then((mapConfig) => {
configOutput.value = mapConfig?.getIndentedJsonString();
configOutput.value = mapConfig?.serialize();

generateLineNumbers('configOutput', 'outputLineNumbers');

// set class and message
message.classList.add('config-json-valid');
message.classList.remove('config-error');
if (mapConfig) {
message.innerHTML = 'File is valid, see console for details...';
document.getElementById('createMap').disabled = true;
if (mapConfig && !mapConfig.errorDetected) {
message.innerHTML = 'URL is valid, waiting for service metadata to be read...';

mapConfig.fetchServiceMetadata().then(() => {
mapConfig.listOfLayerEntryConfig = mapConfig.metadataLayerTree;
configOutput.value = mapConfig?.serialize();
generateLineNumbers('configOutput', 'outputLineNumbers');
message.innerHTML = 'URL is valid, reading of service metadata is complete';
document.getElementById('createMap').disabled = true;
});
} else {
message.innerHTML = 'URL is invalid, see console for details...';
}
Expand All @@ -172,14 +189,14 @@
// get config and test if URL Config is valid
const returnedValue = cgpv.api.configApi.getConfigFromUrl(configUrlArea.value.trim());
returnedValue.then((mapConfig) => {
configOutput.value = mapConfig.getIndentedJsonString();
configOutput.value = mapConfig.serialize();

generateLineNumbers('configOutput', 'outputLineNumbers');

// set class and message
message.classList.add('config-json-valid');
message.classList.remove('config-error');
if (mapConfig.isValid) {
if (!mapConfig.errorDetected) {
message.innerHTML = 'File is valid, see console for details...';
document.getElementById('createMap').disabled = true;
} else {
Expand Down
Binary file modified config-sandbox.html.br
Binary file not shown.
5 changes: 5 additions & 0 deletions configs/OSDP/function-event-swiper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"orientation": "vertical",
"keyboardOffset": 10,
"layers": []
}
Loading

0 comments on commit 237acdf

Please sign in to comment.