Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmaps v3 load event?

Tags:

google-maps

I want to got the visible map when all data is loaded and places too. It's integrated on mobile device program and the 2G connection is too slow, so i want to avoid loading in parts the google maps.

once it's loaded i want to got an message - "the map is loaded" and then show on display.

I tried some functions as

<script type="text/javascript">
$(document).ready(function() {

    google.maps.event.bounds_changed(map, 'idle', function(){
    alert("Map is loaded!");
    });
});

but stilll dont work

like image 662
user1670866 Avatar asked Mar 25 '26 07:03

user1670866


1 Answers

google.maps.event.addListenerOnce(map, 'idle', function(){
  alert("Map is loaded!");
});

This will add a listener to be fired a single time - so the first time the map reaches the 'idle' state - i.e. when it's initially loaded - the function will be executed

EDIT:

Firstly, Please do not make 'suggested edits' but instead reply via comments to an answer.

Secondly, what do you mean the map is loading piece by piece? That's the way the 256x256 tile images are downloaded and there's nothing you can do about that.

Thirdly, you're not using the code that I suggested to you at all. You are using this:

  google.maps.event.addListener(map, 'bounds_changed', function() {
     alert("Картата е заредена!");
  });

when I suggested that you use this:

google.maps.event.addListenerOnce(map, 'idle', function(){
  alert("Map is loaded!");
});
like image 100
Adam Avatar answered Mar 28 '26 01:03

Adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!