Sign in to follow this  
pariyani

Get entity values on map click

Recommended Posts

Hi,

 

 

 

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.

Edited by Guest

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

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.

Share this post


Link to post
Share on other sites

Hey,

 

 

 

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.id == id)

 

lName= entities.lName; sName= entities.sName;

 

}

 

alert("Long Name: "+ lName +", Short Name: "+sName);

 

}

 

 

 

Please let me know if there is a better solution than this.

 

 

 

 

 

Thanks.

Edited by Guest

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

We are glad that your issue is resolved.

Thanks for sharing your idea.

Keep smiling and keep FusionCharting. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this