<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 数据:
