How to embed google map using ajax in wordpress?

I want to embed google map in my wordpress page using ajax.I have dealer listing page and on click of the view map I want to display google map as per the address of dealer. Currently I am using below code to load default map But don’t know how to bind dealer address on click of view map button

<script type = "text/javascript">   
    function initialize() {
    var mapOptions = {
        zoom: 5,
        center: new google.maps.LatLng(3.199739, 101.620391),
        mapTypeId:google.maps.MapTypeId.ROADMAP,    
    };      
}


function loadScript() {
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&' +
      'callback=initialize';
  document.body.appendChild(script);

}
window.onload = loadScript;

</script>

Related posts

Leave a Reply