I have an application which stores the user’s home town, state, and country. I don’t particularly need to do validation; no other part of the application relies on the data, but I would like the formatting to be consistent for vanity and to avoid later having “North Carolina”, “NC”, “north carolina” and so forth all in the database.
Does anyone know of a way to pass Bing maps (I would prefer Bing over Google since I’ve been using it on this project thus far) a search string and get given back an object with the address as interpreted by the service? (i.e. pass in “charlotte, nc” and be given back “Charlotte, North Carolina, United States”)
I’ve looked at VEPlace (on MSDN), but I’m not sure how to ensure I get back the format I’m hoping for from the Name attribute. Anyone have an idea on how best to go about this?
Also, the back-end for the project is ASP.NET MVC, so if there’s a way to do it in C# that involves a controller or something similar that’s totally fine.
I think I may have found the solution: The
GeocodeServiceRequest.ReverseGeocodeRequestmethod (on MSDN) returns aGeocodeResponseclass which has anAddressmember. This in turn has all the attributes required to form the address the way I want. So there will be a controller with an Action to take in the string form of the address, which will send back the properly formatted version.I’m going to try this and update with code in a couple hours. It’s not fully client-side, which is suboptimal, but it looks like it will work well.