Search code examples
google-maps-api-3street-address

Google Maps API v3 - Get map by address ?


i am new to google maps, and i would like to integrate it into my website ( Yellow pages kind of site ).

i currently have the following code:

<!DOCTYPE html>

<html>
<head>
    <title></title>
    <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
        }); 
    </script>
</head>
<body>
    <div id="map_canvas" style="width: 500px; height: 300px; position: relative; background-color: rgb(229, 227, 223);"></div>
</body>
</html>

This code does work, and showing me the map for the specific Lat/Long

but, i want to be able to specifiy an address and not lat/long params, since i do have the addresses of the companies in the phonebook, but do not have the lat/long values.

i tried searching for this, but i only found something similar on the V2 version, which was deprecated.


Solution

  • You can use the google geocoder: http://code.google.com/apis/maps/documentation/geocoding/ Be careful - you can be out of quota and so the request to the geocoder will failed

    Use of the Google Geocoding API is subject to a query limit of 2,500 geolocation requests per day.