//
System is a singleton, so you should use Connections for this - Connections QML Type | Qt QML 5.8
Connections <SPAN class="punctuation token">{</SPAN> target<SPAN class="punctuation token">:</SPAN> System onOnlineStateChanged<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"is online?"</SPAN><SPAN class="punctuation token">,</SPAN> online<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// hide whatever layers you want to hide</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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
If you are not connected, you can expect your online layers to not draw. You can test that on your windows device by turning off your wifi. You might see some data that has been cached, but it will not be able to fetch any new tiles. Instead, you will either need to make a TPK and side load it, or use the Export Tile Cache Task to take a tile service offline. Then, you can use System.isOnline property from ArcGISExtras to switch between your online/offline layer:
pseudocode:
BasemapImagery <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> onlineBasemap <SPAN class="punctuation token">}</SPAN> Basemap <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> offlineBasemap ArcGISTiledLayer <SPAN class="punctuation token">{</SPAN> TileCache <SPAN class="punctuation token">{</SPAN> path<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"/pathToData/data.tpk"</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> Map <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// user ternary operator to switch between the layers whenever the isOnline property changes</SPAN> basemap<SPAN class="punctuation token">:</SPAN> System<SPAN class="punctuation token">.</SPAN>isOnline <SPAN class="operator token">?</SPAN> onlineBasemap <SPAN class="punctuation token">:</SPAN> offlineBasemap <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.