Jump to content
JChartFX Community
  • 0

jchartfx Maps Know What State Is Clicked onclick event


tenstreet_dev

Question

I'm working on implementing the jchartfx maps feature.  However, I'm having a hard time figuring out where to hook into the onclick event.  I'm wanting to navigate to another page based on what state is clicked in the 'US_ContinentalStates.cmf' map.  Is it possible to hook into this event?  I've been able to use some basic jquery as follows:

 

$("#ChartDiv").click(function(evt)
    {
alert('Map Clicked.');
    });
 
I'm just not sure how to get the state from here.
 
Thanks for any help!
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Add this code inside your click handler
 
    if (evt.hitType == cfx.HitType.Other) {
       var shape = evt.targetObject;
       var layer = shape.getLayer();
       var state = shape.getFieldValue("STUSPS");
       alert(state);
    }
 
Note that evt.targetObject when using maps will contain a reference to the shape the user clicked, from there you can get the layer (in case the map has multiple layers such as roads, rivers, etc.), you can also get to any field stored in the map. In the case of US_ContinentalStates the field with the state abbreviation is called STUSPS.
 
Regards,
 
JuanC

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...