Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (75 sloc) 3.71 KB
<apex:page showHeader="false">
This stylesheet contains specific styles for displaying the map on this page. Replace it with your own styles as described in the documentation:
<link rel="stylesheet" href="//"/>
<div id="map"></div>
var lexOrigin = 'https://{!$CurrentPage.parameters.lcHost}';
//Data for Google map
var data;
//Send message to LC
function sendToLC(message) {
if(typeof(lexOrigin) != 'undefined'){
parent.postMessage(message, lexOrigin);
//Receive message from LC
window.addEventListener("message", function(event) {
//If page is public (like used in sites) then be careful about the origin
//if (event.origin !== lexOrigin) {
// Not the expected origin: reject message!
// Handle message
console.log('Data Sent to VF: ',;
data =;
if(typeof( != 'undefined'){
//Load Google Map Script
var script = document.createElement("script");
script.src = "";
}, false);
//Callback when Google Map is loaded
function initMap() {
//Add marker for each point along with text
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.position,
//icon: icons[feature.type].icon,
map: map
var infoWindow = new google.maps.InfoWindow({
content: feature.markerText
marker.addListener('click', function() {, marker);
//Create new map
var map = new google.maps.Map(document.getElementById("map"), JSON.parse(data.mapOptions));
//Set map center
//iterate through map data for each point (even if 1)
var mapData = data.mapData;
for(var i=0, j=mapData.length; i<j; i++){
//Add marker for each point
var myLatlng = new google.maps.LatLng(mapData[i].lat, mapData[i].lng);
addMarker({position: myLatlng, markerText: mapData[i].markerText });
//Let LC know that VF page been loaded along with it's URL
//LC will then send the data
//This is done because LC has no way to know that VF page in iFrame has been loaded, event listener set and ready for data
var vfHost = "{!LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))}";
sendToLC({'state':'LOADED', 'vfHost': vfHost});