我已经能够将一些shapefiles导入到Neo4j 2.3.1。现在如何在地图上查看这些数据?
我已经在GeoServer和uDig上尝试过Wiki的指令,但是它们都已经过时了,我无法让它开始工作。
最近有什么教程或其他工具可以解决这个问题吗?
发布于 2016-03-28 16:57:41
我使用了Mapbox.js中的新4j空间来可视化地图中的几何图形。

对于我的用例,我在新4j空间中索引了美国国会地区的几何图形,然后根据用户点击地图的位置查询空间索引,返回最近的区域,包括WKT字符串和Cypher查询的结果。为了在地图中呈现WKT多边形,我编写了一个简单的javascript函数,将其解析为一个点数组,以添加一个地图注释。
下面是一些相关的代码片段:
创建映射并为映射定义单击处理程序:
L.mapbox.accessToken = MB_API_TOKEN;
var map = L.mapbox.map('map', 'mapbox.streets')
.setView([39.8282, -98.5795], 5);
map.on('click', function(e) {
clearMap(map);
getClosestDistrict(e);
});手柄鼠标单击
/**
* Find the District for a given latlng.
* Find the representative, commitees and subjects for that rep.
*/
function infoDistrictWithinDistance(latlng, distance) {
var districtParams = {
"layer": "geom",
"pointX": latlng.lng,
"pointY": latlng.lat,
"distanceInKm": distance
};
var districtURL = baseURI + findGeometriesPath;
makePOSTRequest(districtURL, districtParams, function (error, data) {
if (error) {
console.log("Error");
} else {
console.log(data);
var params = {
"state": data[0]["data"]["state"],
"district": data[0]["data"]["district"]
};
var points = parseWKTPolygon(data[0]["data"]["wkt"]);
makeCypherRequest([{"statement": subjectsQuery, "parameters": params}], function (error, data) {
if (error) {
console.log("Error");
} else {
console.log(data);
var districtInfo = data["results"][0]["data"][0]["row"][0];
districtInfo["points"] = points;
districtInfo["state"] = params["state"];
districtInfo["district"] = params["district"];
console.log(districtInfo);
addDistrictToMap(districtInfo, latlng);
}
});
}
});将WKT解析为点数组
/**
* Converts Polygon WKT string to an array of [x,y] points
*/
function parseWKTPolygon(wkt) {
var pointArr = [];
var points = wkt.slice(10, -3).split(",");
$.each(points, function(i,v) {
var point = $.trim(v).split(" ");
var xy = [Number(point[1]), Number(point[0])];
pointArr.push(xy)
});
return pointArr;
}代码在这个回购中。您可以看到简单的地图演示这里 (只需单击美国的任何地方即可开始)。最近还有一篇关于这个例子这里的博客文章。
https://stackoverflow.com/questions/36226377
复制相似问题