Get entity values on map click
#1
Posted 16 July 2010 - 03:27 PM
Is there a way to get entity values (including short name, long name, id) by clicking on a map entity using javascript?
For example,
Lets say I click on the State of Texas on a US map and an alert box pops up saying "You clicked on Texas (TX) , Value='1234', entity ID='TX'."
I am sure this is easy but I couldn't find a solution in the forums. Can someone please help with this or point to a link where a similar query is addressed?
*update: The DB Schema does not have Long Names stored for any entity so that is not an option.*
Thanks.
Other Replies To This Topic
#2
Posted 19 July 2010 - 02:46 AM
In this case you need to use your own code in javascript so that it returns the entity values.
Ref.-
<set label='USA' value='235' link="j-myJS-NA,235"/>
<SCRIPT LANGUAGE="JavaScript">
<!--
function myJS(myVar){
window.alert(myVar);
}
//-->
</SCRIPT>
Hope this helps.
Other Replies To This Topic
#3
Posted 19 July 2010 - 10:22 AM
Thanks for the Code, but that was not what I was asking for. I specifically wanted to pull out long and short names of a map entity from the map object itself.
Anyways, I found the solution. The code is as follows:
In the chart XML:
<entity id='123' value='500' link='j-getEntityData-123'/>
//javascript Code
function getEntityData(id) {
var map1 = getMapFromId("mapid");
var entities = map1.getEntityList();//
var lName = "";
var sName = "";
for (i = 1; i < entities.length; i++) {
if (entities[i].id == id)
lName= entities[i].lName; sName= entities[i].sName;
}
alert("Long Name: "+ lName +", Short Name: "+sName);
}
Please let me know if there is a better solution than this.
Thanks.
Other Replies To This Topic
#4
Posted 20 July 2010 - 12:43 AM
We are glad that your issue is resolved.
Thanks for sharing your idea.
Keep smiling and keep FusionCharting.


Back to top
MultiQuote