Find your content:

Search form

You are here

using google maps without a controller


I want to display all of my accounts and leads on a google map in a visualforce page. Problem is that I have the Sales Cloud professorial edition which allows me to write vf pages but not classes. Can I achieve the above without a custom controller?

Attribution to: Dedo

Possible Suggestion/Solution #1


If you have API enabled that's a really good news. Ability to send database queries & updates will be a huge benefit for you. Using AJAX toolkit:

  1. you can decide which accounts to display (if listview filters won't be enough)
  2. you'll get the data in JSON format so no need for listview at all; without traversing the HTML table and collecting data you'll find the my answer on SO a bit better suited
  3. Plus you'll be able to update the records back with the lat/long coordinates. Cached data, no need to geocode, faster map loading.

Check the advanced examples in the toolkit docs for query,retrieve/search (if you plan building a form like I did in my SO answer) and update calls.

(Or a bit more advanced - if you want to display "recently viewed Accounts" this answer about REST API is awesome:


This is going to be painful...

@rao your comment wont work as it seems API access is paid extra in Professional Editions. See this topic on the boards and this idea.

First you'll need a way to display all these Accounts and Leads without querying for data... Do you have any ideas for this?

  • StandardSetController would be best but you can have only one on the page so it'd be Accounts or Leads. There's nice example in documentation how to display them. You won't even need the form I think, just pageBlockTable
  • failing that: you could experiment with embedding two <apex:enhancedList>s on same page? Or <apex:listViews>
  • <apex:relatedList>, <apex:repeat> etc tags probably won't work as you'd need some kind of master record to which all other would be linked.


    <apex:enhancedList type="Account" height="300" rowsPerPage="10" id="AccountList" />
    <apex:enhancedList type="Lead" height="300" rowsPerPage="25"  id="LeadList" />

Then the actual Google Map mashup.

You'll need to fetch the data from the tables to JavaScript variables, geocode the addresses and display them (or do you already have latitude&longitude?). I wrote something like that and published it as StackOverflow answer to How do I integrate Salesforce with Google Maps?.

But as it was over 2 years ago and now the code is simply butt-ugly so I've recently upgraded it. Check the revision history of my answer and decide which version suits you more. If the rev. history is hard to read - you can always view the raw source of original answer.

(disclaimer: I think some bugs might lurk in the old one's geocoding routine, people reported problems with displaying the map:,; I'd recommend salvaging what you can from the new version)

Attribution to: eyescream
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content