LabelLayer是API 3.7以后引入的,为矢量要素提供客户端标注功能。
1、标注要素图层
var citiesSymbol = new TextSymbol().setColor(citiesColor);2、分类标注
citiesSymbol.font.setSize("18pt");
citiesSymbol.font.setFamily("arial");
citiesSymbol.yoffset = 4;
labels.addFeatureLayer(cities, new SimpleRenderer(citiesSymbol), "{CITY_NAME}");
var citiesSymbolSmall = new TextSymbol().setColor(citiesColor);
citiesSymbolSmall.font.setSize("10pt");
citiesSymbolSmall.font.setFamily("arial");
citiesSymbolSmall.yoffset = 4;
var citiesSymbolLarge = new TextSymbol().setColor(citiesColor);
citiesSymbolLarge.font.setSize("14pt");
citiesSymbolLarge.font.setFamily("arial");
citiesSymbolLarge.yoffset = 4;
// 按城市级别分类渲染
var citiesRenderer = new ClassBreaksRenderer(null, "POP_RANK");
citiesRenderer.addBreak({
minValue: 1,
maxValue: 2,
symbol: citiesSymbolLarge
});
citiesRenderer.addBreak({
minValue: 2,
maxValue: 3,
symbol: citiesSymbolSmall
});
labels.addFeatureLayer(cities, citiesRenderer, "{CITY_NAME}");
3、按比例标注
var citiesLargeRenderer = new SimpleRenderer(citiesSymbolLarge);
var citiesScaleDependent = new ScaleDependentRenderer({
rendererInfos: [{
renderer: citiesSmallRenderer,
minScale: 25000000,
maxScale: 10000000
}, {
renderer: citiesLargeRenderer,
minScale: 10000000,
maxScale: 1
}]
})
labels.addFeatureLayer(cities, citiesScaleDependent, "{CITY_NAME}");暂写到这