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?
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:
- you can decide which accounts to display (if listview filters won't be enough)
- 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
- 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
retrieve/search (if you plan building a form like I did in my SO answer) and
(Or a bit more advanced - if you want to display "recently viewed Accounts" this answer about REST API is awesome: https://salesforce.stackexchange.com/a/4244/799).
This is going to be painful...
First you'll need a way to display all these Accounts and Leads without querying for data... Do you have any ideas for this?
StandardSetControllerwould 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
- failing that: you could experiment with embedding two
<apex:enhancedList>s on same page? Or
<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:page> <apex:enhancedList type="Account" height="300" rowsPerPage="10" id="AccountList" /> <apex:enhancedList type="Lead" height="300" rowsPerPage="25" id="LeadList" /> </apex:page>
Then the actual Google Map mashup.
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: https://stackoverflow.com/questions/3566729/salesforce-com-visualforce-google-maps, https://stackoverflow.com/questions/9028682/google-map-integrated-with-salesforce-is-blank; I'd recommend salvaging what you can from the new version)