La page http://atlasnw.free.fr/geoportail/ex...precision.html ne fonctionne plus avec la mise à jour prévue pour la semaine prochaine...
La surcharge de Geoportal.Control.MeasureToolbar.prototype.handleMeasurements est en cause.
La page http://atlasnw.free.fr/geoportail/ex...precision.html ne fonctionne plus avec la mise à jour prévue pour la semaine prochaine...
La surcharge de Geoportal.Control.MeasureToolbar.prototype.handleMeasurements est en cause.
Effectivement, j'ai changé le fonctionnement de handleMeasurements() pour faciliter les surcharges et ajout de nouvelles mesures :
Si l'interface de l'API n'a pas changé, c'est bien le mécanisme d'extension des mesures que j'ai revu.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 /** * Method: handleMeasurements * Display the measure and store the informations on the measure. * The informations on the measure is as follows: * * order; * * measure; * * unit; * * key; * * label; * * targetFormat; * * targetElement; * * accuracy; * * dimension. * * Parameters: * evt - {Event} triggered by OpenLayers.Control.Measure.measure method. * event context is (event.object being the underneath measure control): * * measure : length, area or angle so far measured; * * units : units of measure; * * order : 1 for length, 2 for area, 3 for angle; * * geometry : the path of measurement. * If the evt.object holds a handleMeasurements function, it is then * first called. */ handleMeasurements: function(evt) { if (!evt) { return; } if (typeof(evt.object.handleMeasurements)=='function') { this.lastMeasurement= evt.object.handleMeasurements(evt); } else { var tge= (evt.object.targetElement && evt.object.targetElement.style.display!='none'? evt.object.targetElement : (this.targetElement && this.targetElement.style.display!='none'? this.targetElement : null)); var key= (!(0<=evt.order && evt.order<(evt.object.measurementLabels || Geoportal.Control.MeasureToolbar.LABELS).length) || evt.measure===0? 'wait' : (tge? 'targetElement' : 'default')); var order= (key=='wait'? 0 : evt.order); this.lastMeasurement= { 'order':order, 'measure':evt.measure, 'unit':evt.units, 'key':key, 'label': (evt.object.measurementLabels || Geoportal.Control.MeasureToolbar.LABELS)[order], 'targetFormat':(evt.object.targetFormat || Geoportal.Control.MeasureToolbar.TARGETFORMAT)[key], 'targetElement':tge, 'accuracy':(evt.object.accuracies || Geoportal.Control.MeasureToolbar.ACCURACIES)[evt.units] || '', 'dimension':(order==2? (tge? '<sup>2</sup>':'^2'):'') }; } this.printResult(this.lastMeasurement); }, /** * Method: printResult * Outputs the measurement. * * Parameters: * m - {Array({Object})} the informations about the measurement. */ printResult: function(m) { if (!m) { m= [{ 'order':0, 'measure':0, 'unit':'', 'key':'wait', 'label':Geoportal.Control.MeasureToolbar.LABELS[0], 'targetFormat':Geoportal.Control.MeasureToolbar.TARGETFORMAT['wait'], 'targetElement':this.targetElement, 'accuracy':0, 'dimension':'' }]; } if (!(m instanceof Array)) { m= [m]; } for (var i= 0, l= m.length; i<l; i++) { var title= (m[i].key==='wait'? OpenLayers.i18n('waiting.measurement') : OpenLayers.i18n(m[i].label)); var msg= (m[i].key==='wait'? '' : OpenLayers.String.sprintf( m[i].targetFormat.measure, m[i].accuracy, m[i].measure, OpenLayers.i18n(m[i].unit), m[i].dimension)); if (m[i].targetElement) { if (m[i].targetElement.type=='text') { m[i].targetElement.value= msg || title; } else { m[i].targetElement.innerHTML= OpenLayers.String.sprintf( m[i].targetFormat.result, title, msg); } } else { OpenLayers.Console.info( OpenLayers.String.sprintf( m[i].targetFormat.result, title, msg)); } } },
Dans le cas de Geoportal.Control.Measure.Azimuth cela donne :
Dans le ChangeLog, j'ai écrit un peu en style télégraphique sans noter l'incompatibilité, j'en suis désolé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 /** * APIMethod: handleMeasurements * Prepare the informations for displaying the measure. * * Parameters: * evt - {Event} triggered by OpenLayers.Control.Measure.measure method. * event context is (event.object being the underneath measure control): * * measure : azimuth so far measured; * * units : units of azimuth; * * distance : length of the two points supporting the azimuth computation; * * distanceUnits : units of the length measurement; * * order : 3; * * geometry : the path of measurement. * * Returns: * {Array({Object})} an array with the informations on the azimuth : * * distance between points ; * * angle. */ handleMeasurements: function(evt) { if (!evt) { return; } var die= (this.distanceElement && this.distanceElement.style.display!='none'? this.distanceElement : null); var tge= (this.targetElement && this.targetElement.style.display!='none'? this.targetElement : null); var key= (!(0<=evt.order && evt.order< (this.measurementLabels || Geoportal.Control.MeasureToolbar.LABELS).length) || evt.measure===0? 'wait' : (die && tge? 'targetElement' : 'default')); var order= (key=='wait'? 0 : evt.order); var lastMeasurement= [{ 'order':1, 'measure':evt.distance, 'unit':evt.distanceUnits, 'key':key, 'label':(this.measurementLabels || Geoportal.Control.MeasureToolbar.LABELS)[1], 'targetFormat':(this.targetFormat || Geoportal.Control.MeasureToolbar.TARGETFORMAT)[key], 'targetElement':die, 'accuracy':(this.accuracies || Geoportal.Control.MeasureToolbar.ACCURACIES)[evt.distanceUnits] || '', 'dimension':'' },{ 'order':order, 'measure':evt.measure, 'unit':evt.units, 'key':key, 'label':(this.measurementLabels || Geoportal.Control.MeasureToolbar.LABELS)[order], 'targetFormat':(this.targetFormat || Geoportal.Control.MeasureToolbar.TARGETFORMAT)[key], 'targetElement':tge, 'accuracy':(this.accuracies || Geoportal.Control.MeasureToolbar.ACCURACIES)[evt.units] || '', 'dimension':'' }]; return lastMeasurement; },
* Correction de la désactivation du contrôle Geoportal.Control.Measure: réinitialisation de targetElement si besoin. Geoportal.Control.Measure.Azimuth ouvre un panneau de résultats (distance et angle). Réorganisation de Geoportal.Control.MeasureToolbar pour faciliter les surcharges utilisateurs. Ajout du style gpControlMeasureAzimuthAzimuthInput;
C'est effectivement plus simple une fois que l'on a la solution ...
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager