+1 vote
30 views
by (163k points)

I have a visualforce page component that loads a google map at the push of a button, but it only works by using window.onload in JavaScript which refreshes the page, yet I want to keep the focus on the map and tab without moving the focus to the parent page. If window.onload is not used I cannot initialize/render the map. I may be a little over my head here. Your help will be much appreciated.

  <!--VF component summarized-->

  <div class="col-sm-4">
    <div class="form-group">
        <button id="btn_map_searchtest" type="button" class="btn btn-primary">Go</button>
        <apex:actionFunction name="af_btn_map_search" action="{!getMapMth}" status="ajax_status" oncomplete="hideSpinner();" reRender=""/>
    </div>
  </div>

      <div id="dvMap" style="width: 100%; height: 600px">
      </div>

The js follows:

 /* js summarized */
  var mapicon = '';

  window.onload = function () {
    if ('{!appointmentJson}' !== '') {
      mapicon = JSON.parse('{!appointmentJson}');
      LoadMap();
    }
  };

  function LoadMap() {
     //map code
  }

The apex follows:

/* apex summarized */

public List<My_Schedule__c> getMap(){
    //querying and creating json data
}

public void getMapMth(){
    getMap(); //calls getMap                
} 

1 Answer

Welcome to Memory Exceeded, where you can ask questions and receive answers from other members of the community.
...