js中
//添加点
var point1 = new Point({
longitude: 121.429,
latitude: 31.153
});
//设置点形状以及颜色
var markerSymbol = {
type: "text",
color: "#25A5f7",
text: "\ue613",
font: {
size: 34,
family: "CalciteWebCoreIcons"
}
};
//设置该点属性
var pointGraphic1 = new Graphic({
geometry: point1,
symbol: markerSymbol,
popupTemplate: {
title: "Shanghai"
}
});
//给该点属性设置标号
pointGraphic1.attributes = {
"number": 1
}
//添加点
var point2 = new Point({
longitude: 116.422,
latitude: 39.918
});
//设置点形状以及颜色
var pointGraphic2 = new Graphic({
geometry: point2,
symbol: markerSymbol,
popupTemplate: {
title: "Beijing"
}
});
//给该点属性设置标号
pointGraphic2.attributes = {
"number": 2
}
//将多点添加到地图图层中
var graphicLayer = new GraphicsLayer({
graphics: [pointGraphic1, pointGraphic2]
});
map.add(graphicLayer);
效果:

本文详细介绍了如何使用JavaScript在地图上添加并自定义点标记,包括设置点的坐标、形状、颜色及弹窗标题,同时展示了如何批量添加多个点到地图图层。
1962

被折叠的 条评论
为什么被折叠?



