i'm almost there... when the map loads, the onMouseOver listener is active. Simple popups are displayed, highlightgraphic added. OnMouseOut also works removing the highlightgraphic. When the identify toggle button is clicked, onMouseOver is no longer active and executeIdentifyTask fires... so far so good.However, if you try and click a point that was previously hovered on, executeIdentifyTask is not fired, but rather, only the simple popup is displayed?? any advice? TIA!
//globals
var featlayer;
var identifyListener;
var facilsHoverHandle;
var facilsHoverHandleOut;
function init() {
featlayer = new esri.layers.FeatureLayer("url",{
mode:esri.layers.FeatureLayer.MODE_ONDEMAND,
id: 'facs',
outFields:["*"]
});
facilsHoverHandle = dojo.connect(featlayer, "onMouseOver", showHoverPopup);
facilsHoverHandleOut = dojo.connect(featlayer, "onMouseOut", hideHoverPopup);
}
function showHoverPopup(evt){
map.graphics.enableMouseEvents();
var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle(evt.graphic.attributes.facil_name);
infoTemplate.setContent("<b>${facil_name}</b>");
map.infoWindow.resize(245,125);
var highlightSym = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([255,0,0]), 1),
new dojo.Color([0,255,0,0.25]));
evt.graphic.setInfoTemplate(infoTemplate);
var content = evt.graphic.getContent();
map.infoWindow.setContent(content);
var title = evt.graphic.getTitle();
map.infoWindow.setTitle(title);
highlightGraphic = new esri.Graphic(evt.graphic.geometry,highlightSym);
map.graphics.add(highlightGraphic);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
}
function hideHoverPopup(evt){
map.graphics.remove(highlightGraphic);
}
//toggles identify onClick and featlayer onMouseOver listeners on/off
function activateIdentify(){
if (dijit.byId("tool_identify").checked) {
map.infoWindow.hide();
dojo.disconnect(featlayerHoverHandle);
dojo.disconnect(featlayerHoverHandleOut);
identifyListener = dojo.connect(map, "onClick", executeIdentifyTask);
} else {
dojo.disconnect(identifyListener);
facilsHoverHandle = dojo.connect(featlayer , "onMouseOver", showHoverPopup);
facilsHoverHandleOut = dojo.connect(featlayer , "onMouseOut", hideHoverPopup);
}
}
<button dojotype="dijit.form.ToggleButton" id="tool_identify" title="Identify"
onclick="activateIdentify();" style="cursor:crosshair;">
<img src="images/infoIcon.png" width="34px" height="34px" alt="" />
</button>