How to get Latitude and longitude

We are working on a project that is supposed to display a dynamic map of an address. The address is entered at the run-time by the user and up-front we don't know what the address is going to be. When the map is displayed, we need to display a marker where the address is.

As far as we know, we need the latitude and longitude of an address before we can call either the Google or Bing map APIs.

The question is: Is there a way to find out the latitude and longitude of an address?

P.S. We know that the Census has the latitude and longitude of all the zip codes but that wouldn't help in this particular case.
mrasooliAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

earthwareCommented:
both the bing maps and google maps apis will take and address and geocode it for you and display it on the map, job done
Molnár IstvánHelpDesk / ProgrammerCommented:
Molnár IstvánHelpDesk / ProgrammerCommented:
you can get the longitude and latitude from an address with geocoding
i you are developing in asp.net , i recommand using this: http://en.googlemaps.subgurim.net - its free, and easy to use (example using subgurim in geocoding: http://en.googlemaps.subgurim.net/ejemplos/ejemplo_97000_GeoCoding.aspx)
see example how to get longitude/latitude from an address

hope it helps
<!--add this in html head-->
<script language="javascript" type="text/javascript">
     var map = null;
    var geocoder = null;
    function load() 
    {
      if (GBrowserIsCompatible()) 
      {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(47.4984056, 19.0407578), 13);
        map.setUIToDefault();
        map.addControl(new GOverviewMapControl());
        geocoder = new GClientGeocoder();
      }
    }
    function GeoKodolo(address) 
    {
      if (geocoder) 
      {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert("No address with name: "+address);
            } 
            else {
              map.setCenter(point, 17);
              var marker = new GMarker(point);
              map.addOverlay(marker);
            //  map.setUIToDefault();
            //  map.addControl(new GOverviewMapControl());
              marker.openInfoWindowHtml("The searched address: "+address+"<br/>Address latitude: "+marker.getPoint().lat()+"<br/>Address longitude: "+marker.getPoint().lng());
            }
          }
        );
      }
    }
 
</script>    

<!--add this in html body-->

<input type="text" size="60" name="address" id="addr" value="Budapest, Hungary" >
	<a onclick="GeoKodolo(document.getElementById('addr').value)">search</a>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Molnár IstvánHelpDesk / ProgrammerCommented:
Did you finally resolve your problem with the coords?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
GIS/GPS Programming

From novice to tech pro — start learning today.