jquery: how can i load the Google Maps API via ajax?

前端 未结 2 961
萌比男神i
萌比男神i 2020-12-05 12:00

Before you reply: this is not as straight foward as you\'d expect!

  • I have a \'show on map\' button which when clicked opens a dialogbox/lightbox with the googl
2条回答
  •  -上瘾入骨i
    2020-12-05 12:48

    thanks for pointing me in the right direction Andrew, my problem was that the callback in the api request is mandatory for loading the api on demand.

    Here is my final jquery code:

    //in doc.ready
    $('img.map').click(function(){      
        var rel = $(this).attr('rel');      
        $('body').data('map_href', rel ).append('');
    })
    
    
    function show_map(){
        $.fn.colorbox({
            href:$('body').data('map_href')
        })
    }
    

提交回复
热议问题