Google markers

Discussion in 'ASP.NET / ASP.NET Core' started by wisemx, Aug 1, 2008.

  1. Hi,
    For help with something like this you will do better to post for help on Microsoft Channel 9's TechOff.
    If you don't have an account there sign up, it's the right place to get help with tough code.
    http://channel9.msdn.com/Forums/Techoff/
     
  2. I'm confused - why do you need to use PHP to export data into XMLto put markers and otherwise interact with google maps? You don't.

    Google maps is all javascript based... consult with their API documentation. Their (admittedly simple)examples are really straightforward, even if you're really uncomfortable with javascript like me.

    As an alternative, you might want to have a look at Subgurim's .NET google maps control: http://en.googlemaps.subgurim.net/ It's super easy - you interact with it's methods and properties right in your C#/VB code and it renders the map for you automagically. I started with this on my own site, but then eventually decided to output my own javascript code as the one side effect of this control is that it was a bit more bulky than I wanted viewstate wise, and it had a side effect of flickering ever so slightly during a partial page postback.
     
  3. Hello
    I am using visual web developer 2008 express and have a SQL database on my site. My database collects data from a user interface and the address is broken down into seperate columns (address, city, state, zip). In order for Google maps to place a marker in these locations I need to use PHP sataements to export the table data into an XML format. Hopefully this will allow google maps to find and asign the lat/lng coordinates to my addresses. I have sample code to do this using PHP's domxml function, PHP echo, or PHP's DOM function to output XML. Can I do this on this server and if so which is my best choice? I believe google maps needs the address to be in a string. Can I please get some help with this as I have wasted lots of time and have gotten nowhere.
    Thank you for any help.
     
  4. ksnyc


    Thank you for the help. I will look at that site. I have checked with Google API documentation and agree the maps are easy. However my problem is I don't know how to iterate through the table, send a request to the geocoder, and update the table with the geocoded lat and lon values. I believe I need this database update to take place when the user submits the form. To complicate things my addresses that the user interface sends to my database are broken down into individual columns (address, city, state , zip). I believe the google geocoder needs to see a string address of all 4 columns.


    If you know a solution I will be greatful.


    Thank you again
     
  5. MK...,

    You have the right idea. Looks like you may just need to read up on reading/writing to the database and the google geocoder.

    The fact that your addresses are separated in multiple fields is not a problem - you'll just need to concatenate them to a single string before passing it to google. (From my experience any string that you can manually search foron maps.google.com and have it find the exact location will work.)

    I want to say there were a couple ways you could make the geocode request, but I do it performing an HTTPWebRequest (see http://wiki.asp.net/page.aspx/285/httpwebrequest/for examples on that) and specify that I want google to return a comma separated response, which is something like"lat,lng,accuracy"and maybe a status code too, i forget. Then split that resultresult to grab the lat and lng and then update your database with these values.

    Note: it's fine -andmore simple-to get the geocode when the user submits the from, but that's not the only time you could do it. In my case I have the user submit the form and I save the location they entered and thats it. Then, when it comes to plot on the map I determine whether I have a lat/lng saved for that particular record and if so plot, if not, perform the geocode request, update the database, then plot it. Then the next time it's mapped, I'll just pull the lat/lng from my database.
     
  6. ksnyc


    Thank you for the help. I am glad to know that I can use my database as I planned. I will try to weigh which I can learn the easiest.


    I'll let you know how it goes. I probably will need more help.
     

Share This Page