我得到了这个 Openlayer 问题。
我试图从一些物体中得到一堆点。我相信这不应该很难。
我正在将 st_astext 传递给 WKT 阅读器以创建一个Openlayers.Geometry.Point()
要添加到将包含所有行的初始层的功能。但这似乎不起作用。谁能看到我做错了什么?
//Routes for each bridge?
vesselPosition = new OpenLayers.Layer.Vector('Vessels');
var wkt = new OpenLayers.Format.WKT();
$.ajax({
url: "/ajax/getPositions",
dataType: 'json',
success: function(result) {
for (var reportID in result) {
//Store the object at hand.
var data = result[reportID];
//Get all the positions and print them onto the vesselpoisition layer.
var positions = data.positions;
var listOfPoints = new Array();
for (var index in positions) {
var positionData = positions[index];
var point= wkt.read(positionData.st_astext);
listOfPoints.push(point.geometry);
}
var pointmap = new OpenLayers.Geometry.LineString({points:listOfPoints});
vesselPosition.addFeatures(pointmap);
};
}
});