【发布时间】:2021-05-02 10:56:21
【问题描述】:
我正在尝试使用 mapkit js 在苹果地图上绘制折线。无法在地图上显示任何内容。
我的项目由地图上的许多位置组成。所有标记都在地图上,单击一个标记将打开信息窗口并在地图上绘制一条折线。
map = new mapkit.Map("map");
function plottrailsCompound(data,map){
if(data.reststatus.status == "OK"){
if(annotations){
map.removeAnnotations(annotations);
annotations = [];
}
var landmarkAnnotationCallout = {
calloutElementForAnnotation: function(annotation) {
var cccDiv = calloutForLandmarkAnnotation(annotation,map);
return cccDiv;
},
calloutAppearanceAnimationForAnnotation: function(annotation) {
return "scale-and-fadein .4s 0 1 normal cubic-bezier(8, 1, 0, 1.5)";
}
};
}
}
function calloutForLandmarkAnnotation(data,map){
DrawPolyLine(map);
}
function DrawPolyLine(map){
var points = [[37.73438, -119.56517], [37.73435, -119.56513], [37.73431, -119.56509]];
var coords = points.map(function(point) {
return new mapkit.Coordinate(point[0], point[1]);
});
var style = new mapkit.Style({
lineWidth: 2,
lineJoin: "round",
lineDash: [8, 4],
strokeColor: "#F0F"
});
var polyline = new mapkit.PolylineOverlay(coords, { style: style });
map.addOverlay(polyline);
}
我正在calloutForLandmarkAnnotation 中绘制我的信息窗口,我没有在这里显示。 DrawPolyLine 函数有点变量,它有三个坐标,但实际上我有更多。有些有大约 100 个坐标。如果你们需要任何其他信息来解决这个问题,请告诉我。
【问题讨论】:
标签: javascript mapkit apple-maps mapkitannotation