Skip to content

Commit

Permalink
doc : mise à jour jsdoc
Browse files Browse the repository at this point in the history
build : mode 'hot reload' actif (exemples / jsdoc)
fix : dispatch event 'mapLoaded' sans autoconf
  • Loading branch information
lowzonenose committed Dec 11, 2020
1 parent 9d6c2f7 commit b9564b9
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"clean": "echo \"Warning: target not yet implemented!\" && exit 0",
"test:serve": "webpack-dev-server --hot --config webpack.test.serve.js",
"doc:serve": "webpack-dev-server --config webpack.config.3d --content-base jsdoc/ --port 9001 --open 'google-chrome'",
"sample:3d:serve": "webpack-dev-server --config webpack.config.3d --https --open-page samples/index-3d-map.html --content-base . --output-public-path '/dist/3d/' --port 9001 --open 'google-chrome'",
"sample:2d:serve": "webpack-dev-server --config webpack.config.2d --https --open-page samples/index-2d-map.html --content-base . --output-public-path '/dist/2d/' --port 9001 --open 'google-chrome'",
"sample:3d:serve": "webpack-dev-server --config webpack.config.3d --mode=development --https --open-page samples/index-3d-map.html --content-base . --output-public-path '/dist/3d/' --port 9001 --open 'google-chrome'",
"sample:2d:serve": "webpack-dev-server --config webpack.config.2d --mode=development --https --open-page samples/index-2d-map.html --content-base . --output-public-path '/dist/2d/' --port 9001 --open 'google-chrome'",
"stat:2d": "npm run build:2d:src -- --profile --json > map-2d.json",
"stat:3d": "npm run build:3d:src -- --profile --json > map-3d.json",
"build": "npm-run-all --print-label --print-name build:*:*",
Expand Down
6 changes: 5 additions & 1 deletion samples-src/pages/2d/page-controlsOptions-bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ <h1>Ajout d'une carte avec Gp.Map.load() et l'ensemble des options possibles de
var map = Gp.Map.load('geoportalMap',{
configUrl : "{{resources}}/autoconf.js", // apiKey : "{{apikey}}",
azimuth : 45,
zoom : 12,
zoom : 13,
center : {
x : -511270,
y : 6151620
},
// proxyUrl : "{{ proxy }}?url=",
layersOptions : {
'ORTHOIMAGERY.ORTHOPHOTOS': {
Expand Down
54 changes: 52 additions & 2 deletions src/Interface/IMapBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ IMap.prototype = {

// appel du service d'autoconfiguration si nécessaire
// Dans tous les cas, le reste s'exécute dans _afterGetConfig
var map = this;
if (needsGetConfig) {
// autoconf locale ? on met par defaut un callbackSuffix à ""
// à moins qu'on ne le surcharge (non documenté).
Expand All @@ -419,7 +420,6 @@ IMap.prototype = {
this.mapOptions.autoconfUrl) {
callbackSuffix = callbackSuffix || "";
}
var map = this;
Services.getConfig({
apiKey : this.apiKey,
serverUrl : this.mapOptions.configUrl || this.mapOptions.autoconfUrl,
Expand All @@ -435,14 +435,21 @@ IMap.prototype = {
}
});
} else {
this._afterGetConfig(Config);
// HACK : je mets cette fonction dans la pile des callbacks afin que son
// execution soit differée par le moteur javascript !
// ceci afin qu'un abonnement à l'event "mapLoaded" puisse se faire...
setTimeout(function () {
map._afterGetConfig(Config);
});
}
},

/**
* callback d'appel à l'autoconf (ou non).
*
* @param {Object} configResponse - configuration associée à apiKey.
* @fires mapLoaded
* @fires configured
* @private
*/
_afterGetConfig : function (configResponse) {
Expand All @@ -463,6 +470,49 @@ IMap.prototype = {
if (!this.mapOptions.hasOwnProperty("layersOptions")) {
if (this._isConfLoaded) {
// FIXME : trouver l'info dans l'autoconf ... ou pas ?
// param par defaut :
// "ORTHOIMAGERY.ORTHOPHOTOS::GEOPORTAIL:OGC:WMTS" : {
// minZoom : 0,
// maxZoom : 19,
// queryable : true,
// opacity: 1,
// format : "wmts",
// position : 0,
// title : "Photographies aériennes",
// description : "Photographies aériennes",
// url : "https://wxs.ign.fr/an7nvfzojv5wa96dsga5nk8w/geoportail/wmts",
// layer : "ORTHOIMAGERY.ORTHOPHOTOS",
// projection : "EPSG:3857",
// tileMatrixSet : "PM",
// topLeftCorner : {
// x:-20037508,
// y:20037508
// },
// resolutions : [156543.033928041,78271.51696402048,39135.758482010235,19567.87924100512,9783.93962050256,4891.96981025128,2445.98490512564,1222.99245256282,611.49622628141,305.7481131407048,152.8740565703525,76.43702828517624,38.21851414258813,19.10925707129406,9.554628535647032,4.777314267823516,2.388657133911758,1.194328566955879,0.5971642834779395,0.2985821417389697,0.1492910708694849,0.0746455354347424],
// matrixIds : ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21"],
// styleName : "normal",
// outputFormat : "image/jpeg",
// originators : [{
// name : "IGN",
// attribution : "Institut National de l'Information Géographique et Forestière",
// url : "https://www.ign.fr"
// }],
// quicklookUrl : "https://wxs.ign.fr/static/pictures/ign_ortho.jpg",
// metadata : [{"url":""},
// {"format":"xml","url":"https://wxs.ign.fr/geoportail/csw?service=CSW&version=2.0.2&request=GetRecordById&Id=IGNF_BDORTHOr_2-0.xml"},
// {"format":"xml","url":"https://wxs.ign.fr/geoportail/csw?service=CSW&version=2.0.2&request=GetRecordById&Id=SPOT5.xml"},
// {"format":"xml","url":"https://wxs.ign.fr/geoportail/csw?service=CSW&version=2.0.2&request=GetRecordById&Id=NCL-DITTT-ORTHO.xml"},
// {"format":"xml","url":"https://wxs.ign.fr/geoportail/csw?service=CSW&version=2.0.2&request=GetRecordById&Id=IGNF_BDORTHOr_2-0.xml"},
// {"format":"xml","url":"https://wxs.ign.fr/geoportail/csw?service=CSW&version=2.0.2&request=GetRecordById&Id=IGNF_ORTHOHR_1-0.xml"}
// ],
// legends : [
// {
// format : "application/pdf",
// url : "https://www.geoportail.gouv.fr/depot/fiches/photographiesaeriennes/geoportail_dates_des_prises_de_vues_aeriennes.pdf",
// minScaleDenominator : null
// }
// ]
// }
}
this.mapOptions.layersOptions = {
"ORTHOIMAGERY.ORTHOPHOTOS::GEOPORTAIL:OGC:WMTS" : {}
Expand Down
2 changes: 1 addition & 1 deletion src/Interface/IMapListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IMap.prototype.setSelectable = function (controlOpts) {};
*
* | eventId | description |
* |-|-|
* | mapLoaded | fired when map has finished loading. |
* | mapLoaded | fired when map has finished loading. Callback function handles a {@link Gp.MapLoadedEvent} object. |
* | geolocated | fired when map has finished centering by geolocation. Callback function handles a {@link Gp.GeolocatedEvent} object.|
* | located | fired when map has finished centering by geocoding. Callback function handles a {@link Gp.LocatedEvent} object. |
* | configured | fired when map has finished loading geoportal configuration. Callback function handles a {@link Gp.ConfiguredEvent} object |
Expand Down
2 changes: 2 additions & 0 deletions src/Interface/IMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Services } from "geoportal-extensions-openlayers";
* @param {Object} opts - opts de geocodage
* @param {String} opts.location - localisant
* @param {Array.<String>} opts.locationType - types de localisants
* @fires located
* @private
*/
IMap.prototype.centerGeocode = function (opts) {
Expand Down Expand Up @@ -69,6 +70,7 @@ IMap.prototype.centerGeocode = function (opts) {
/**
* envoie d'une requête de géolocalisation par IP.
*
* @fires geolocated
* @private
*/
IMap.prototype.centerGeolocate = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var mapLoadedEvent = {
* | defaultFeaturesStyle | {@link Gp.StyleOptions Gp.StyleOptions} | optional | | Default style options for vector layers features (KML, GPX, GeoJSON). |
* | layersOptions | Object | optional | | Layers to add to the map and their options. Associative array mapping ids of layers to display and their properties.<br/>For each layer, the id may be either the name of a Geoportal layer (eg : "ORTHOIMAGERY.ORTHOPHOTOS") available with the given apiKey or an id of your choice for external resources. The properties associated to each ID are given as {@link Gp.LayerOptions}.<br/>For Geoportal Layers availables with the given apiKey, values are automaticaly fetched from key configuration. You only need to specify a {@link Gp.LayerOptions} Object with properties you want to overide. |
* | controlsOptions | Object | optional | | Controls to add to the map and their options. Associative array mapping the control's name (keys) with a Boolean (value) for activating / deactivating or with their properties (values given as {@link Gp.ControlOptions}). See {@link Gp.ControlOptions} for availables controls list and their properties. |
* | mapEventsOptions | Object | optional | | Map's events to listen for interaction. Associative array mapping an event from the map (keys) with a function triggered by this event (values given as {Function}). See {@link Gp.Map#listen Gp.Map.listen()} for available event Ids and their associated events objects. |
* | mapEventsOptions | Object | optional | | Map's events to listen for interaction. Associative array mapping an event from the map (keys) with a function triggered by this event (values given as {Function}). See [Gp.Map.listen()](Gp.Map.html#.listen) for available event Ids and their associated events objects. |
* | minZoom | Integer | optional | 0 | Zoom level beyond which the user can't zoom out. |
* | maxZoom | Integer | optional | 21 | Zoom level beyond which the user can't zoom in. |
* | configUrl or AutoConfUrl | String | optional | | Geoportal config url to use instead of the default dynamic configuration service based on apiKey param. See this [tutorial](http://ignf.github.io/geoportal-access-lib/latest/jsdoc/tutorial-optimize-getconfig.html) to generate a config file suitable with this parameter. |
Expand Down
2 changes: 1 addition & 1 deletion src/OpenLayers/OlMapLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ OlMap.prototype._checkLayerParams = function (layerOpts) {
*
* @param {String} layerId - layer identifier
* @param {Boolean} toGrayScale - indicate transformation direction (from or to grayscale)
*
* @fires change:grayScaled
* @private
*/
OlMap.prototype._changeLayerColor = function (layerId, toGrayScale) {
Expand Down
40 changes: 31 additions & 9 deletions src/Utils/MapLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,41 @@ var MapLoader = {
* @param {String | DOMElement} div - The HTML element or its id where the map will be loaded.
* @param {Gp.MapOptions} [mapOptions] - Options for loading the map.
* @example
* Gp.Map.load(
* 'geoportalMap',
* var map = Gp.Map.load(
* 'viewer-map',
* {
* apiKey : "YOUR_API_KEY",
* center : {
* location : "rue pasteur, Saint-Mandé"
* apiKey: "YOUR_API_KEY",
* reloadConfig: true,
* isWebGL2: false,
* enginePath3d: "path/to/itowns.js",
* viewMode: "3d",
* center: {
* location: "rue pasteur, Saint-Mandé"
* },
* zoom : 16,
* layersOptions : {
* 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD' : {}
* zoom: 16,
* tilt: 0,
* azimuth: 45,
* controlsOptions: {
* mousePosition: {},
* search: { maximised : true }
* },
* mapEventsOptions: {
* "mapLoaded": window.initMap,
* "layerChanged": window.callbackLayerChanged,
* "zoomChanged": window.callbackZoomChanged,
* "centerChanged": window.callbackCenterChanged,
* "azimuthChanged": window.callbackAzimuthChanged,
* "tiltChanged": window.callbackTiltChanged
* },
* layersOptions: {
* 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD': {}
* }
* }
* );
* );
*
* // abonnement à l'evenement "mapLoaded"
* map.listen("mapLoaded", function (e) { console.log("objet map", e); });
*
* @returns {Gp.Map} - The Geoportal map.
*/
load : function (div, mapOptions) {
Expand Down
25 changes: 25 additions & 0 deletions webpack.config.2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,31 @@ module.exports = (env, argv) => {
],
devtool : (devMode) ? "eval-source-map" : false,
// stats : "verbose",
devServer : {
// proxy: {
// "/samples/resources/proxy/" : {
// secure: false,
// target: "http://localhost/proxy/proxy.php" // proxy à deployer en local !
// }
// },
stats : "errors-only",
// host : "localhost",
// https: true,
// port : 9001,
// hot : true,
// contentBase : path.join(__dirname),
// publicPath : "/dist/2d/",
// openPage : "/samples/index-2d-map.html",
// open : "google-chrome",
watchOptions : {
watch : true,
poll : true
},
overlay : {
errors : true,
warnings : false
}
},
optimization : {
/** MINIFICATION */
minimizer: [
Expand Down
25 changes: 25 additions & 0 deletions webpack.config.3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@ module.exports = (env, argv) => {
],
devtool : (devMode) ? "eval-source-map" : false,
stats : "verbose",
devServer : {
// proxy: {
// "/samples/resources/proxy/" : {
// secure: false,
// target: "http://localhost/proxy/proxy.php" // proxy à deployer en local !
// }
// },
stats : "errors-only",
// host : "localhost",
// https: true,
// port : 9001,
// hot : true,
// contentBase : path.join(__dirname),
// publicPath : "/dist/3d/",
// openPage : "/samples/index-3d-map.html",
// open : "google-chrome",
watchOptions : {
watch : true,
poll : true
},
overlay : {
errors : true,
warnings : false
}
},
optimization : {
/** MINIFICATION */
minimizer: [
Expand Down

0 comments on commit b9564b9

Please sign in to comment.