开发者

Google Maps API GroundOverlay Complete Event

is there a way to, w/ google maps v3, listen to an event that will indicate a groundoverlay asset has been loaded? I'm loading an image onto the map and would like to be notified when the asset has completed downloading and has been presented to the client. An开发者_如何学编程y ideas?


As of 2021 Dec, I can confirm that @Trott idle event will NOT work at all.

idle event fired early before any ground overlay image even start loading.

see this example

https://transparentgov.net:3200/googlemaps111/default?layer_id=7&layer=Zoning_Merge&center_lat=33.721999270778305&center_long=-116.28975468931803&center_zoom=17&url=https%3A%2F%2Fgis.la-quinta.org%2Farcgis%2Frest%2Fservices%2FPlanning%2Fzoning1%2FMapServer&panto=0

Google Maps API GroundOverlay Complete Event

However, in another post, I post a working example

The idea is you need use create a html image object,

  new Image()

then set source let it downloading image

   image.src

Then attach event

     image.onload = function

The whole working source code is here

Google Maps API GroundOverlay Complete Event

The working example is here

https://transparentgov.net:3200/googlemaps12/default?layer_id=0&layer=SilverRock_MasterPlan_29Nov2016_s200-images.jpg&center_lat=33.65789936781538&center_long=-116.25862990762825&center_zoom=15&url=https%3A%2F%2Fgis.la-quinta.org%2Farcgis%2Frest%2Fservices%2FCommunity_and_economic%2FSilver_Rock_Master_Plan%2FMapServer&panto=0&overlayOpacity=8&overlayType=overlayType_image

Google Maps API GroundOverlay Complete Event


A straight reading of the Google Maps API v3 documentation would seem to suggest that this wouldn't work, but I've managed to do this using the idle event with addListenerOnce(). (If that doesn't work for you, edit your question to show the code you tried and we'll see if we can get it working.)

The idle event seems to fire exactly once as a way of sort of saying "map is loaded and ready to go" even though the documentation seems to suggest that a pan or zoom needs to happen to trigger it.

Since this is (to my knowledge) undocumented behavior (at least in any official documentation), it runs the risk of suddenly not working one day when the API is updated. You can make the choice to either live with that risk or try to guard against it by specifying the version of the API that you want in your <script> tag that loads the API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜