0
一些信息: 我得到了一個主層(地圖),即時通過線串從JSON結果中獲取點之間的線條。Openlayers自定義標記
(問題) 我跟着一個例子在線上如何自定義我加入點。但這不起作用。 (只看底部的功能。)
代碼:
//'listOfPoints' is an array containing all the point objects.
var pointmap = new OpenLayers.Geometry.LineString(listOfPoints);
var lastpoint = listOfPoints[listOfPoints.length -1];
var vesselLayer = new OpenLayers.Layer.Vector(data.bridge_name);
if (lastpoint != null) {
var markerLayer = getPOI(lastpoint);
vesselLayer.addFeatures([pointmap,markerLayer]);
} else {
vesselLayer.addFeatures([new OpenLayers.Feature.Vector(pointmap)]);
}
// Function for creating a marker and returning it to the caller.
function getPOI(point) {
//This was also tried without the "Style" property. (Only the externalGraphic line)
var temp_feature = new OpenLayers.Feature.Vector(
point,
style: { externalGraphic: '/assets/img/marker.png', graphicHeight: 16, graphicWidth: 16, graphicXOffset:8, graphicYOffset:8 }
);
return temp_feature;
}
太謝謝你了!我其實在我的腳本中有{style:{}}。但我在粘貼中出於某種原因改變了它。抱歉!所以這個null參數訣竅!謝謝! – Christer