需求是图标有hover效果 ,如下
思路 :
1、创建图片标记,并赋值;
args.rendererArgs = new RenderArgs();
args.rendererArgs.type = RenderType.CLASSBREAKS;
args.rendererArgs.attributeField = "value";
var symbolNormal = new PictureMarkSymbolArgs(); symbolNormal.url = getMapImageIcon(remoteMeterName,"0"); symbolNormal.height = 40; symbolNormal.width = 40; symbolNormal.xoffset = 0; symbolNormal.yoffset = 0; args.rendererArgs.symbols.push(symbolNormal); var symbolNormalFocus = new PictureMarkSymbolArgs(); symbolNormalFocus.url = getMapImageIcon(remoteMeterName,"1"); symbolNormalFocus.height = 40; symbolNormalFocus.width = 40; symbolNormalFocus.xoffset = 0; symbolNormalFocus.yoffset = 0; args.rendererArgs.symbols.push(symbolNormalFocus); var symbolNormalLight = new PictureMarkSymbolArgs(); symbolNormalLight.url = getMapImageIcon(remoteMeterName, "2"); //正常高亮图标 symbolNormalLight.height = 40; symbolNormalLight.width = 40; args.rendererArgs.symbols.push(symbolNormalLight); var symbolAlarmLight = new PictureMarkSymbolArgs(); symbolAlarmLight.url = getMapImageIcon(remoteMeterName, "3"); //报警高亮图标 symbolAlarmLight.height = 40; symbolAlarmLight.width = 40; args.rendererArgs.symbols.push(symbolAlarmLight); args.rendererArgs.values.push(0); args.rendererArgs.values.push(0.9); args.rendererArgs.values.push(1.9); args.rendererArgs.values.push(2.9); args.rendererArgs.values.push(3.9);
2、在创建图层的时候写入mouse-over事件,并修改移入时的velue值;并刷新图层;完成。
layer.on("mouse-over", lang.hitch(this, function (evt) {
dijitPopup.close(dialog);
var g = evt.graphic;
if(g.attributes.value=="0"){ g.attributes.value = "2"; layer.refresh(); }else if(g.attributes.value=="1"){ g.attributes.value = "3"; layer.refresh(); }
}))