需要用到的js脚本
require(["esri/symbols/WebStyleSymbol",], function (WebStyleSymbol)
从官网获取一个Symbol模型
var flySymbol = {
type: "web-style", // autocasts as new WebStyleSymbol()
styleName: "EsriRealisticTransportationStyle",
name: "Eurocopter_H125_-_Flying"
};
定义一个Symbol接收体
var temp = new GraphicsLayer();
var SymbolGraphic = new Graphic({
geometry: {
type: "point", // autocasts as new Point()
x: 103.1660414,
y: 43.5026283,
z: 150
}
});
调整尺寸并添加到图层中,官方说明WebStyleSymbol没有height,width属性,需要使用fetchSymbol()函数下载到缓存中再修改其对应的属性
var styles = new WebStyleSymbol();
//styles.type = "web-style";
styles.styleName = "EsriRealisticTransportationStyle";
styles.name = "Eurocopter_H125_-_Flying";
var tempStyles = styles.fetchSymbol();
tempStyles.then(function (flySymbol) {
var tempSymbol = flySymbol;
tempSymbol.symbolLayers.items[0].height *= 5;
tempSymbol.symbolLayers.items[0].width *= 5;
tempSymbol.symbolLayers.items[0].depth *= 5;
SymbolGraphic.symbol = tempSymbol;
temp.add(SymbolGraphic);
});
map.add(temp);