function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sunil NandipatiSunil Nandipati 

Google GeoCoding

Can you correct me if i am missing something.  

My controller class

public with sharing class BillingAddresses {
 public List<Account> AccountsList {get;set;}
 public BillingAddresses() {
  AccountsList = [SELECT ID, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry FROM Account LIMIT 10];

----- VF Page

<apex:page sidebar="false" showHeader="false" cache="false" controller="BillingAddresses">
      html, body, #map_canvas {
        margin: 0;
        padding: 0;
        height: 100%;
    <script src=""></script>    
      <script src=""></script>
    <script src=""></script>
        var map;       
        function initialize() {
            // set the map options in the format that V3 of googlemaps expects
            var mapOptions = {
                zoom: 4,
                center: new google.maps.LatLng(32.5206608,-86.80249),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            // attach our map to the map_canvas div
            map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
            // Pull the data in from the SOQL and use visualforce to create the javascript calls            
            <apex:repeat value="{!AccountsList}" var="Account">              
                showAddress("{!JSENCODE(Account.Name)}", "{!JSENCODE(Account.Name)}  <a href='../{!}' target='_blank'>Details</a>", "{!Account.BillingStreet}", "{!Account.BillingCity}","{!Account.BillingState}", "{!Account.BillingPostalCode}","{!Account.BillingCountry}");
        } // function initialize()

        google.maps.event.addDomListener(window, 'load', initialize);
        function showAddress(title, content, street, city, state, postalcode, country) 
            var address = street + city + state + postalcode + country;
                sforce.connection.sessionid = '{!$Api.Session_ID}';
                var geocoder = new google.maps.Geocoder();
                var geocoderRequest = { address: address }
                geocoder.geocode(geocoderRequest, function(results, status)
                if(status == google.maps.GeocoderStatus.OK) 
                    var googleAddress = results[0].formatted_address;
                    var Lat = results[0];
                    var Long = results[0].geometry.location.lng();
            // convert our raw values to the format that google expects                                 
            var latlng = new google.maps.LatLng(parseFloat(Lat), parseFloat(Long));
            if (latlng != null) {
                // create an info window            
                var infowindow = new google.maps.InfoWindow({
                    content: content
                // Create a marker on the map                   
                var marker = new google.maps.Marker({
                    position: latlng,
                    map: map,
                    title: title                        
                // Add an event to the marker so the info window will appear when it is clicked
                google.maps.event.addListener(marker, 'click', function() {
            } // check for null latlng due an error parsing
        } // end show address    

    <div id="map_canvas" style="width: 100%; height: 100%"></div>

Hi Sunil - Did you resolve this issue.  If so will you please post your fix?

Thank you.