level4designs

Converter For Iso Country 2 Digit Names To Fusionmaps Internal Id's

Recommended Posts

I'm curious if anyone has a function that converts the 2 digit standard country code format to the internal ID country codes that fusion maps uses? strange that it would not use the standard, like they have already done on the states version in the US map...

 

I would love a function to this... I have one for the states in php like this.

 

 

function convert_state($name, $to='name') {

$states = array(

array('name'=>'Alabama', 'abbrev'=>'AL'),

array('name'=>'Alaska', 'abbrev'=>'AK'),

array('name'=>'Arizona', 'abbrev'=>'AZ'),

array('name'=>'Arkansas', 'abbrev'=>'AR'),

array('name'=>'California', 'abbrev'=>'CA'),

array('name'=>'Colorado', 'abbrev'=>'CO'),

array('name'=>'Connecticut', 'abbrev'=>'CT'),

array('name'=>'Delaware', 'abbrev'=>'DE'),

array('name'=>'Florida', 'abbrev'=>'FL'),

array('name'=>'Georgia', 'abbrev'=>'GA'),

array('name'=>'Hawaii', 'abbrev'=>'HI'),

array('name'=>'Idaho', 'abbrev'=>'ID'),

array('name'=>'Illinois', 'abbrev'=>'IL'),

array('name'=>'Indiana', 'abbrev'=>'IN'),

array('name'=>'Iowa', 'abbrev'=>'IA'),

array('name'=>'Kansas', 'abbrev'=>'KS'),

array('name'=>'Kentucky', 'abbrev'=>'KY'),

array('name'=>'Louisiana', 'abbrev'=>'LA'),

array('name'=>'Maine', 'abbrev'=>'ME'),

array('name'=>'Maryland', 'abbrev'=>'MD'),

array('name'=>'Massachusetts', 'abbrev'=>'MA'),

array('name'=>'Michigan', 'abbrev'=>'MI'),

array('name'=>'Minnesota', 'abbrev'=>'MN'),

array('name'=>'Mississippi', 'abbrev'=>'MS'),

array('name'=>'Missouri', 'abbrev'=>'MO'),

array('name'=>'Montana', 'abbrev'=>'MT'),

array('name'=>'Nebraska', 'abbrev'=>'NE'),

array('name'=>'Nevada', 'abbrev'=>'NV'),

array('name'=>'New Hampshire', 'abbrev'=>'NH'),

array('name'=>'New Jersey', 'abbrev'=>'NJ'),

array('name'=>'New Mexico', 'abbrev'=>'NM'),

array('name'=>'New York', 'abbrev'=>'NY'),

array('name'=>'North Carolina', 'abbrev'=>'NC'),

array('name'=>'North Dakota', 'abbrev'=>'ND'),

array('name'=>'Ohio', 'abbrev'=>'OH'),

array('name'=>'Oklahoma', 'abbrev'=>'OK'),

array('name'=>'Oregon', 'abbrev'=>'OR'),

array('name'=>'Pennsylvania', 'abbrev'=>'PA'),

array('name'=>'Rhode Island', 'abbrev'=>'RI'),

array('name'=>'South Carolina', 'abbrev'=>'SC'),

array('name'=>'South Dakota', 'abbrev'=>'SD'),

array('name'=>'Tennessee', 'abbrev'=>'TN'),

array('name'=>'Texas', 'abbrev'=>'TX'),

array('name'=>'Utah', 'abbrev'=>'UT'),

array('name'=>'Vermont', 'abbrev'=>'VT'),

array('name'=>'Virginia', 'abbrev'=>'VA'),

array('name'=>'Washington', 'abbrev'=>'WA'),

array('name'=>'West Virginia', 'abbrev'=>'WV'),

array('name'=>'Wisconsin', 'abbrev'=>'WI'),

array('name'=>'Wyoming', 'abbrev'=>'WY')

);

 

$return = false;

foreach ($states as $state) {

if ($to == 'name') {

if (strtolower($state['abbrev']) == strtolower($name)){

$return = $state['name'];

break;

}

} else if ($to == 'abbrev') {

if (strtolower($state['name']) == strtolower($name)){

$return = strtoupper($state['abbrev']);

break;

}

}

}

return $return;

}

Share this post


Link to post
Share on other sites

Hi,

 

I am afraid, currently we do not have any function to avail this feature.

 

However, we have mad a note of the same and shall update it in our wishlist.

 

Thank you for your continued patience and patronage.-

Share this post


Link to post
Share on other sites

Hi,

 

I am afraid, currently we do not have any function to avail this feature.

 

However, we have mad a note of the same and shall update it in our wishlist.

 

Thank you for your continued patience and patronage.-

 

 

so how do people currently do it? is everyone just hard coding in the country ID?

Share this post


Link to post
Share on other sites

I would like an answer to the question above. 

 

I am currently in the process of testing FusionMaps XT to see if we can buy it and use it in our product. However we need it to be very dynamic, as we don't know in advance what data will be bound. We cannot use the internal IDs, especially if there's no programmatic way to convert a name or id to the internal id.

 

So basically if all I have is a JSON array with country names and values, there is no way to map that data automatically?

Share this post


Link to post
Share on other sites

I would like an answer to the question above. 

 

I am currently in the process of testing FusionMaps XT to see if we can buy it and use it in our product. However we need it to be very dynamic, as we don't know in advance what data will be bound. We cannot use the internal IDs, especially if there's no programmatic way to convert a name or id to the internal id.

 

So basically if all I have is a JSON array with country names and values, there is no way to map that data automatically?

Hi,

 

We sincerely apologize for the delay.

 

Please note that short or long names of an entity might be duplicate within the same map. Hence, Internal IDs are the unique values to identify an entity for FusionMaps to plot the corresponding values correctly. The Internal ID for each entity is pre-defined in the code as per the standards. This cannot be derived from external names, but can be changed by defining Custom entity IDs.

Ref.- http://docs.fusioncharts.com/maps/Contents/?how_to_use/CustomID.html

 

Hence, if you have the country names, you can retrieve the Internal ID for the entities from our Map Specification sheet or create your own using the actual IDs and pass it to the map with the values to render the map.

Ref.- http://docs.fusioncharts.com/maps/Contents/?MapSS/WorldMap.html

 

Hope this clarifies the query.

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