none
AutoSuggest RRS feed

  • Question

  • Hi , We are migrating from google maps to bing. Till now it's been great. The dev document of maps implementation and AutoSuggest was outstanding. 

    But i'm stuck at small problem. The AutosuggestManager callback gives address object.In adminDistrict of  address is  giving us state's name in full form. But in our application we need the state's abbreviation as NJ,NY,CA etc. Other fields subtitle or formattedSuggestion also gives full state names. Is there any optoin where we can have that shorten form of state name.

    Any help will be appreciated.

    Thanks!! 

    Tuesday, April 4, 2017 2:55 PM

Answers

  • Unfortunately there isn't a built in option to get the state abbreviation, however this is fairly easy to handle. Here is a simple code block that does this:

    var stateAbb = { 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA', 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC', 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL', 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA', 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN', 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV', 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY', 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR', 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD', 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA', 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY'}; 
    
    function getStateAbb(state){
    	var abb = stateAbb[state.toLowerCase()];
    	if(abb){
    		return abb;
    	}
    	
    	return state;
    }


    [Blog] [twitter] [LinkedIn]

    Tuesday, April 4, 2017 3:28 PM

All replies

  • Unfortunately there isn't a built in option to get the state abbreviation, however this is fairly easy to handle. Here is a simple code block that does this:

    var stateAbb = { 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA', 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC', 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL', 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA', 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN', 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV', 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY', 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR', 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD', 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA', 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY'}; 
    
    function getStateAbb(state){
    	var abb = stateAbb[state.toLowerCase()];
    	if(abb){
    		return abb;
    	}
    	
    	return state;
    }


    [Blog] [twitter] [LinkedIn]

    Tuesday, April 4, 2017 3:28 PM
  • Thanks Ricky,

    Actually we are using Bing maps to search address for whole US and Canada and sometimes outside of US & Canada also. If this is the only workaround the we might have to add abbreviation for Us and Canada and then handle exception for other countries if they comes. 

    Tuesday, April 4, 2017 6:41 PM