Hallo zusammen. Ich habe einige Probleme mit einer Webkarte und einer Web-App, die ich über das ArcGIS-Online-Portal meiner Organisation erstelle.
Ich habe eine Webkarte mit mehreren Layern und für einige Pop-ups verschiedener Layer Attributausdrücke konfiguriert. Der von mir verwendete Code sieht so aus:
<SPAN class="comment token">// Linien/Polygone in Punkte umwandeln</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>
Das Pop-up funktioniert einwandfrei, aber wenn ich in der Web-App die Attributtabelle dieses Layers anzeigen möchte, werden keine Datensätze geladen. In der Chrome-Konsole wird der Fehler „Error: Runtime Error: Cannot call member method on null.“ angezeigt.
Wenn ich den Code wie folgt ändere:
<SPAN class="comment token">// Linien/Polygone in Punkte umwandeln</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>
wird das Problem tatsächlich behoben. Das ist natürlich nicht ideal, da es für Benutzer viel schwieriger zu lesen ist. Es scheint, als würde der Zugriff auf die Geometrieattribute das Problem verursachen.
Hat jemand eine Idee, woran das liegen könnte?