目錄
地圖聚合API
https://openlayers.org/en/latest/examples/cluster.html
通過地圖平移縮放事件控制地圖四至範圍內地圖刷新和加載詳細點控制。最終實現效果如下:
Java Redis示例
添加geojson數據:
/**
* 更新GEOHASH值
* @param dwCode
* @param coordinate
* @param memberName "HLYID-score"
*/
public static void positonToGeohash(String dwCode,String hlyId,GeoCoordinate coordinate,String memberName){
String storeKey=XHT_ZZJG_GEOPOSITION+dwCode;
String expireKey=XHT_ZZJG_GEOEXPIRE+dwCode;
RedisUtil.geoadd(storeKey, coordinate, memberName);
// 設置超時過期
RedisUtil.zadd(expireKey,System.currentTimeMillis(),memberName);
Set<String> expiredKeys = RedisUtil.zrangeByScore(expireKey, 0, System.currentTimeMillis()-30*60*1000);
if(expiredKeys!=null && expiredKeys.size()>0) {
//刪除超時的數據
RedisUtil.zrem(storeKey,expiredKeys.toArray(new String[expiredKeys.size()]));
RedisUtil.zrem(expireKey,expiredKeys.toArray(new String[expiredKeys.size()]));
//zzjgList.toArray(new String[zzjgList.size()])
//TODO : 兩個集合中的size不一致時,需要按照expiredKeys中爲標準刪除storeKey中多餘的數據
}
RedisUtil.expire(expireKey, Constants.MOBILE_TOKEN_KEY_HALF_HOUR);//Constants.MOBILE_TOKEN_KEY_HALF_HOUR
RedisUtil.expire(storeKey, Constants.MOBILE_TOKEN_KEY_HALF_HOUR);
}
完整代碼請下載連接(沒有的自行補全):https://download.csdn.net/download/boonya/12048388
缺少的工具類請參考:Redis連接池及單節點工具與多Redis節點管理工具