-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
2Questions
-
2Replies
Mass Geocoding using Google maps API V3
Hello all I am still very new to SFDC so bear with me :smileyhappy: . So i have successfully made a visualforce page that will Geocode and capture the lon/lat values of a single account address(thanks to theses boards :) now i wanted to see is if there is a way to run this visualforce page for all accounts in one batch, I do understand that they have to be spaced out to avoid the over limit error I have seen this done before when i used and edited find nearby (thanks to Mr.Reid) but the way i implemented the geocoding is more so through javascript than through apex unlike find nearby. Also I want to keep my code for Google maps API V3 i'm trying to avoid using V2. Heres my code and thanks in advance:
VF Page:
<apex:page standardController="Account" extensions="Monty" id="pg"> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var myOptions = { zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false } var map; var marker; var geocoder = new google.maps.Geocoder(); var address = "{!Account.BillingStreet}, " + "{!Account.BillingCity}, " + "{!Account.BillingPostalCode}, " + "{!Account.BillingCountry}"; var infowindow = new google.maps.InfoWindow({ content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingCountry}" }); geocoder.geocode( { address: address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK && results.length) { //alert( "latitude : " + results[0].geometry.location.lat() ); //alert( "longitude : " + results[0].geometry.location.lng() ); var latt = results[0].geometry.location.lat(); var lngg = results[0].geometry.location.lng(); document.getElementById('alat').value = latt; document.getElementById('alon').value = lngg; if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { //create map map = new google.maps.Map(document.getElementById("map"), myOptions); //center map map.setCenter(results[0].geometry.location); //create marker marker = new google.maps.Marker({ position: results[0].geometry.location, map: map, title: "{!Account.Name}" }); //add listeners google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); google.maps.event.addListener(infowindow, 'closeclick', function() { map.setCenter(marker.getPosition()); }); } } else { $('#map').css({'height' : '15px'}); $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct."); resizeIframe(); } }); function resizeIframe() { var me = window.name; if (me) { var iframes = parent.document.getElementsByName(me); if (iframes && iframes.length == 1) { height = document.body.offsetHeight; iframes[0].style.height = height + "px"; } } } }); function setHidden() { var Longitude = document.getElementById('pg:form:hlon'); var hiddenRep = document.getElementById('pg:form:hlat'); hiddenRep.value = document.getElementById('alat').value; Longitude.value = document.getElementById('alon').value; } </script> <style> #map { font-family: Arial; font-size:12px; line-height:normal !important; height:150px; width:300px; background:transparent; } </style> <div id="map" style="font-size: 24px"><br/>There is a problem with the address verify that the address is correct</div> <apex:form id="form"> <div> <label for="alat"><b>Latitude and Longitude: </b></label> <input id="alat"/> <input id="alon"/> </div> <apex:actionFunction name="kill" action="{!change}"/> <apex:inputHidden id="hlat" value="{!alat}"/> <apex:inputHidden id="hlon" value="{!alon}"/> </apex:form> <script> function save() { kill(); } window.onload = setTimeout(setHidden,750) window.onload = setTimeout(save,1500) </script> </apex:page>
Controller:
public with sharing class Monty { public Monty(ApexPages.StandardController controller) { account2 = [select id,BillingStreet, BillingCity, BillingPostalCode,BillingCountry,Latitude__c,Longitude__c, Name from Account where id = :ApexPages.currentPage().getParameters().get('id')]; } private Account account2; public Account getAccount() { return account2; } public String alat{get;set;} public String alon{get;set;} } public PageReference change(){ account2.Latitude__c = alat; account2.Longitude__c = alon; update account2; PageReference reference=new PageReference('https://na12.salesforce.com/'+ account2.id); reference.setRedirect(true); return reference; } }
PS I am sure there is some misc code still there that does belong anymore.
-
- CSOLANOJR
- May 23, 2012
- Like
- 0
- Continue reading or reply
Salesforce android sdk "install.vbs" issue
Hello I am currently having issues running the install.vbs script for the android sdk. I recieve an error at line 25 at character 1, I have ran it through the command line and through windows. I have tried to skip this step due to the errors but i get tons of errors with the sample projects. I am using windows 7 64 bit and the latest sdk 1.02.
Thank you in advance for any help you can provide.
-
- CSOLANOJR
- December 20, 2011
- Like
- 0
- Continue reading or reply
Salesforce android sdk "install.vbs" issue
Hello I am currently having issues running the install.vbs script for the android sdk. I recieve an error at line 25 at character 1, I have ran it through the command line and through windows. I have tried to skip this step due to the errors but i get tons of errors with the sample projects. I am using windows 7 64 bit and the latest sdk 1.02.
Thank you in advance for any help you can provide.
- CSOLANOJR
- December 20, 2011
- Like
- 0
- Continue reading or reply