Bonjour à tous. J’ai quelques problèmes avec une carte web et une application web que je crée via le portail ArcGIS Online de mon organisation.
J’ai une carte web avec plusieurs couches et j’ai configuré certaines fenêtres contextuelles de différentes couches avec des expressions attributaires. Le code que j’utilise ressemble à ceci :
<SPAN class="comment token">// Convertir les lignes/polygones en points</SPAN>
<SPAN class="keyword token">var</SPAN> PointGeometry <SPAN class="operator token">=</SPAN> <SPAN class="token function">Centroid</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Geometry</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> pointX <SPAN class="operator token">=</SPAN> PointGeometry<SPAN class="punctuation token">.</SPAN>x<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> pointY <SPAN class="operator token">=</SPAN> PointGeometry<SPAN class="punctuation token">.</SPAN>y<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token function">text</SPAN><SPAN class="punctuation token">(</SPAN>pointX<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">":"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">text</SPAN><SPAN class="punctuation token">(</SPAN>pointY<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
La fenêtre contextuelle fonctionne bien, mais lorsque j’essaie d’afficher la table attributaire de cette couche dans l’application web, aucun enregistrement ne se charge. Dans la console de Chrome, j’obtiens l’erreur « Error: Runtime Error: Cannot call member method on null. »
Modifier le code comme suit :
<SPAN class="comment token">// Convertir les lignes/polygones en points</SPAN>
<SPAN class="keyword token">var</SPAN> PointGeometry <SPAN class="operator token">=</SPAN> <SPAN class="token function">Centroid</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Geometry</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token function">text</SPAN><SPAN class="punctuation token">(</SPAN>PointGeometry<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
résout effectivement le problème. Évidemment, ce n’est pas idéal, car cette valeur est beaucoup plus difficile à lire pour les utilisateurs. Il semble que l’accès aux attributs de la géométrie soit à l’origine du problème.
Une idée de la raison pour laquelle cela se produit ?