How To Get the Attributes for the Map Feature That the Mouse is Over
After the map has loaded, use the subscribe API to set a
function to be called when the current feature changes.
<html.
<head>
<script type="text/javascript" src="map_data/swfobject.js"></script>
<script type="text/javascript" src="map_data/avenza.js"></script>
<script type="text/javascript">
var theMap = AVENZA.embedViewer("map", "750", "500",
{
baseURL:"map_data/",
loadedCB: onMapLoaded,
flashSecuritySandbox: AVENZA.AUTO_SANDBOX
}
);
function onMapLoaded() {
theMap.subscribe(AVENZA.FEATURE, "onMouseOver");
}
function onMouseOver(feature) {
var o = document.getElementById("output");
if (o) {
o.innerHTML = "The mouse is now over: " + feature.attributes.STATE_NAME;
}
}
</script>
</head>
<body>
<div style="position:relative">
<div id="map">
</div>
<hr>
<div id="output">
Move the mouse over the map.
</div>
</div>
</body>
</html>
You can see a live example here.
