私はこの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);
};
}
});