How to check if Google Maps API is loaded?

前端 未结 10 2209
花落未央
花落未央 2020-12-04 16:12

How to check if Google Maps API (v3) is loaded?

I do not want to execute mapping scripts if the API did not load due to internet connectivity problems (web page is h

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 17:00

    You might consider using the Google Loader

    google.load("maps", "3", {callback: myFn});
    

    It will load your designated javascript file, then execute the callback, specified in the optionalSettings argument.

提交回复
热议问题