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
chiranchiran 

Regarding multiple markerd in googlemap

Here i want to display multiple markers on googlemap by passing data from the salesforce database instead of hard coding as if i have done before...So now i passed salesforce data in to an array in javascript .. Array having all Latitude values  related to a
particular city or address which i filter in my vpage picklist field ... FOr city==hyderabad i query all Latitude__c and Longitude__c  whose city =hyderabad..and passed this o/p to list and passed the list output to my array in javascript....SO array is as follows...


  var array3 = new Array();
 array3 = '{!leadrecords2}'.replace('[','').replace(']','').split(',');


for(i=0;i<array3.length;i++)
{
  var k=array3[i];
  alert(k);
    
}

here iam iterating through the loop to fetch all the values .... now i want to pass this values dynamically instead of hardcodingto the constructor new GLatLng( x, y ) Instead of x,y variables which i harrdcoded i want to pass all the values in my array3 as x argument and similarly i want to pass other array which has list of longitude values as y argument to that consructor so that the constructor fetches all the values in to array latlng[];



where leadrecords2 is as follows:

List<String> leadrecords2= new List<String>();
for(Integer i=0;i<leadrecords.size();i++)
          {
 leadrecords2.add(leadrecords[i].Latitude__c);
         }



and leadrecords is as follows


private List<Lead> leadrecords;
String query = 'SELECT  City,Latitude__c,Longitude__c FROM Lead WHERE City LIKE \''+city+'%\'';
        
        leadrecords = Database.query(query);


// this is the code for displaying multiple markers in the google map...


 
function showmarkers()
         {
         var x= '{!lat}';
         var y='{!longt}';
         var x1='{!lat1}';
          var y1='{!longt1}';
       var combi= '{!lat}' + ',' + '{!longt}';
        var combi1= '{!lat1}' + ',' + '{!longt1}';
  var map = new GMap2(document.getElementById("map_canvas"));
       
 // array were i wabnt to store all latitude and longitude values by passing my array s as arguments to constructor GLatLng




         var latlng1 =
         [
     new GLatLng( x, y ),
     new GLatLng(x1,y1)     
];
   map.setCenter( new GLatLng( 0, 0 ), 0 );
   
   for ( var i = 0; i < latlng1.length; i++ )
  {
    var marker = new GMarker( latlng1[ i ] );
    map.addOverlay( marker );
  }
var latlngbounds = new GLatLngBounds( );
  for ( var i = 0; i < latlng1.length; i++ )
  {
    latlngbounds.extend( latlng1[ i ] );
  }

  // #2b -- set center using the calculated values


  map.setCenter( latlngbounds.getCenter( ), map.getBoundsZoomLevel( latlngbounds ) );



          /*map.addoverlay will add markers to the maps overlay by calling new gmarker() passing the latitude and longitude as parameter... */


       
        
               marker.openInfoWindowHtml(combi);
            marker.openInfoWindowHtml(combi1);
       
        }

jkucerajkucera

What's your question?