arcgis javascript text
作者:互联网
var texts = '[{"name":"测试文本1","X":"107.1455","Y":"34.37218"},{"name":"测试文本2","X":"107.1455","Y":"34.37218"}]';
function ShowText(texts) {
var items = eval('(' + texts + ')');
//字体
var font;
require(["esri/symbols/Font"], function (Font) {
font = new esri.symbol.Font();
font.setSize("36pt");
font.setFamily("宋体");
});
for (var i = 0; i < items.length; i++) {
var pt = new esri.geometry.Point(items[i].X, items[i].Y, map.spatialReference);
//var txtPoint;
//require(["esri/geometry/webMercatorUtils"], function (webMercatorUtils) {
// txtPoint = webMercatorUtils.geographicToWebMercator(pt);
//});
var textSymbol = new esri.symbol.TextSymbol(items[i].name, font, new esri.Color([25, 237, 170, 0.8])); //strCarNo
//textSymbol.font.setDecoration(180);
//textSymbol.angle=45;
//textSymbol.setFont(font);
//textSymbol.setOffset(60,-4);
var graphicText = new esri.Graphic(pt, textSymbol); // ,null
map.graphics.add(graphicText);
map.centerAt(pt);
}
}
ShowText(texts);
标签:text,javascript,textSymbol,arcgis,items,var,new,font,esri 来源: https://www.cnblogs.com/devgis/p/16545870.html