<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />上一篇文章創建了世界日/夜地圖,其中白天由背景位圖表示,夜晚由空心輪廓表示。此範例將展示如何透過繪製 IP 位置、在下方地圖的夜間部分創建黃色薄霧,為夜間地圖添加一些有趣的細節。
點擊看大圖...

IP 位置來自腳本從 MaxMind 下載的檔案。他們的資料非常酷,可以讓你將 IP 位址對應到位置。在這裡不使用它。這是他們的通知:
This example includes GeoLite data created by MaxMind, available from http://www.maxmind.com.
由於該檔案非常大,因此該 JSL 將檢查資料是否已下載到您的 $temp 目錄中。如果 TRY 語句無法開啟表格(第一個語句,在逗號之前),則抓住的一部分嘗試(逗號後的陳述)將下載並儲存新副本。下載使用兩個 open() 語句:第一個取得 zip 存檔,第二個對從 zip 檔案讀取的 CSV 成員進行文字匯入。在儲存表格(僅包含緯度、經度列)之前,<
// download the maxmind zip file http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip// it isn't required, but provides a beautiful nighttime glow around parts of the world with internet connections.Try( cityloc = Open( "$temp/cityloc.jmp" ); // try to open an existing saved table , // if that fails, open a zip archive from the internet za = Open( "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip", "zip" ); zipMemberList = za << dir;// there are two files in the zipped archive, with any luck, this is still the name... // this zip archive member has the Lat,Lon data citylocblob = za << read( zipMemberList[If( // the member name includes a date that changes. this should pick the right member Ends With( zipMemberList[1], "GeoLiteCity-Location.csv" ), 1, Ends With( zipMemberList[2], "GeoLiteCity-Location.csv" ), 2, . // if this happens, perhaps there is an extra file in the zip? )], Format( blob ) ); cityloc = Open( citylocblob, // open understands a blob can hold CSV data columns( // there are only two cols we need Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Column( "latitude", Numeric, "Continuous", Format( "Best", 10 ) ), Column( "longitude", Numeric, "Continuous", Format( "Best", 10 ) ), Omitted Column( . ), Omitted Column( . ) ), Import Settings( // runs fast when it doesn't have to guess End Of Line( CRLF, CR, LF ), End Of Field( Comma, CSV( 1 ) ), Strip Quotes( 1 ), Use Apostrophe as Quotation Mark( 0 ), Scan Whole File( 1 ), Treat empty columns as numeric( 0 ), CompressNumericColumns( 0 ), CompressCharacterColumns( 0 ), CompressAllowListCheck( 0 ), Labels( 1 ), Column Names Start( 2 ), Data Starts( 3 ), Lines To Read( "All" ), Year Rule( "20xx" ) ) ); // add Creative Commons Attribution-ShareAlike 3.0 Unported License text MaxMind wants... cityloc << settablevariable( "MaxMind", "This table includes GeoLite data created by MaxMind, available from http://www.maxmind.com" ); cityloc<);
您將獲得大約 3/4 百萬個位置,這些位置將在頂部地圖的夜間區域的邊界內創建黃白色區域(並且您將獲得不同的行數,因為它們經常更新表格):

腳本的下一部分使用來自的時區函數回覆幾個帖子。需要 GMT 時間才能將地圖太陽/陰影定位在正確的位置,現在。腳本的其餘部分與上一個腳本,只需向 GraphBox 添加一個額外的腳本來繪製額外的位置(以及一個用於將位置加載到經緯度矩陣中的小腳本):
Try( IPdt = cityloc; lat = IPdt:latitude << getasmatrix; lon = IPdt:longitude << getasmatrix;, // data not available? lat = []; lon = [];);g[framebox( 1 )] << addGraphicsScript( 3, // before shape's new position, after the shadow transparency(.2); Marker( Color State( {0.8, 0.8, 0.7} ),lon, lat ););附註:如果您的電腦時鐘漂移超過幾秒,時區函數將不會傳回整數。我的家用電腦關閉了大約 4 秒,報告為 4.999,而不是 5(因為腳本中的捨入函數要求小數點後三位)。這樣的捨入可能會影響結果,這取決於數字的使用方式。
try() 確保 Lat,Lon 是矩陣,如果出現問題,可能為空。此圖形腳本根據緯度、經度矩陣建立一個標記,並將 RGB 顏色設定為淺黃色圖形。0.2 的透明度使得重複點比單點顯示得更強烈。黃色使圖表的白天部分中的點不太明顯,並且一些地圖紋理在這些點下丟失。
即將推出:捕獲 Twitter 數據:
