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);
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/278589.html