_________________________________________________________
Start 11.00 a.m.
_________________________________________________________
Yesterday i played around with Subgurim, a tool that you can add that allows you to use ASP to code maps instead of javascript. So today i will be using that to get the geocodes of locations when a user adds an address.
http://en.googlemaps.subgurim.net/
Today i did the geocoding of addresses. At the moment it puts together all the data from the text boxes and gets the geocode from that. If the user clicks on check geocode it will show them on teh map where that location is. If they click on save they will get a warning asking if they are sure they dont want to check the geocode first. If they dont there is a possibilty that its the wrong place, and either way there might be an error.
I added in a small amount of validation on the text boxes using RequiredFieldValidators (thanks cheekymohnkey! for the suggestion vs writing checks). I havent done any error checking or validation with the geocoding yet however.
The Subgurim controles are fantastic, just like programming c sharp. Below ive added some code to show how easy it is to do all this. Basically it just passes in the address, then creates a new lat lng object which is passed into a marker, and setting the map to centre.
public void getGeocode()
{
string code = txtStreetNumber.Text + "," + txtStreetName.Text + "," + txtSuburb.Text + "," + txtCity.Text + "," + txtCity.Text + "," + txtCountry.Text;
string Key = System.Configuration.ConfigurationManager.AppSettings.Get("http://maps.google.com/maps");
GeoCode geocode = GMap.geoCodeRequest(code, Key);
GLatLng latlng = new GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);
GMarker marker = new GMarker(latlng);
GMap1.addGMarker(marker);
GMap1.setCenter(latlng, 8);
lblGeocodeText.Text = Convert.ToString(latlng);
}
Ive now finished off the adding and editing of both management and client addresses with all the geocoding going all fine as it appears. This isnt including the error checking i havent done yet.. doo dee doo. I also made a point to load up the map to the location when users goes to edit, this way the map is showing the address, and also i wanted to learn how to split the text and turn int a double, because i'm going to have to do that very soon. One day when the copy and paste from virtual machine works i might get around to putting code in here... /sigh. For the rest of the night, now that ive met that one small milestone, i will update my UML diagram. If i manage to comer out before i finish it, i'll upload it tomorow night. I also have a little bit of renaming to do... hard to keep to your own naming conventions when your in a rush. I also understand that some of the design, as in where ive put code isnt the best, so i'll play around with some of that (providing i get time of course....).
Theres alot of things I cant portray and show in this UML, mainly because i am using some grid views and form views, so i'm not writing my own functions to do the saving deleting and updating. Some however i am. This isnt anywhere near done, but by looking at it you can see exactly what ive done on the system so far.
Saved string to geocode code
string geocode = lcManagementAddress.propertyGeocode;
string[] codePart = geocode.Split(new char[] { ',' });
string lat = codePart[0];
string lng = codePart[1];
GMap1.resetMarkers();
GLatLng latlng = new GLatLng(Convert.ToDouble(lat), Convert.ToDouble(lng));
GMarker marker = new GMarker(latlng);
GMap1.addGMarker(marker);
GMap1.setCenter(latlng, 14);
So i just grab the geocode, split it in half, assign two variable to the array values, then pass those into the GLatLng object. Then i can use this to add markers etc. Or in the case of getting routes, i can get directions, then use those directions to do calculations on which order to get the route from Google.
Tomorow i wont be doing much project work until late at night, as i have INF to do all day, then class.
_________________________________________________________
Finish 4.00 a.m. 14 hours
_________________________________________________________
http://www.csharp-station.com/HowTo/StringJoinSplit.aspx
Welcome
I'm a student and this blogg has been created to keep information on a daily to weekly basis about my project that i am doing to get my Bachelor of Information Technology. This is based on my progress, and a place to put all of my information, not entirely a proper blogg. Though sometimes i feel like i'll be talking to myself... Any ways, enjoy and feel free to comment. If your wondering what this project is and dont want to read every single post, just go to the Proposal link, or any of the "posts worth looking at" below.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment