How to use tiles loaded

4,564 views
Skip to first unread message

jimmyt1988

unread,
Sep 28, 2010, 9:06:32 AM9/28/10
to Google Maps JavaScript API v3
Hi all,

I need to do a function after the google maps controls have loaded...
I found tilesloaded but am unsure of how to implement it. Basically
looking for a callback of when google maps scripts have finished doing
their jazz.

var latlng = new google.maps.LatLng(32.505338, -98.349152);
var myOptions = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE,
navigationControl: true,
scrollwheel: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.DEFAULT,
position: google.maps.ControlPosition.RIGHT
},
tilesloaded : function(){
alert("hi");
customiseLargeMapControl();
}
};
var map = new
google.maps.Map(document.getElementById("map_canvas"),
myOptions);

Any tips?

jimmyt1988

unread,
Sep 28, 2010, 10:41:03 AM9/28/10
to Google Maps JavaScript API v3
Ok a better question may have been: Is there a callback after the map
has completely loaded. For example I might want to say "google maps
has completely loaded".

geoco...@gmail.com

unread,
Sep 28, 2010, 11:08:01 AM9/28/10
to Google Maps JavaScript API v3
On Sep 28, 7:41 am, jimmyt1988 <jamestrus...@hotmail.co.uk> wrote:
> Ok a better question may have been: Is there a callback after the map
> has completely loaded. For example I might want to say "google maps
> has completely loaded".

No (at least not now). This thread has a discussion of that:
http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/a6fe7d22d50de69f/64f822e9e83bc38f?lnk=gst&q=geodesic#64f822e9e83bc38f
see Ben Appleton's comments starting around post #12.

-- Larry

>
> On Sep 28, 2:06 pm, jimmyt1988 <jamestrus...@hotmail.co.uk> wrote:
>
>
>
> > Hi all,
>
> > I need to do a function after the google maps controls have loaded...
> > I found tilesloaded but am unsure of how to implement it. Basically
> > looking for a callback of when google maps scripts have finished doing
> > their jazz.
>
> > var latlng = new google.maps.LatLng(32.505338, -98.349152);
> >     var myOptions = {
> >         zoom: 4,
> >         center: latlng,
> >         mapTypeId: google.maps.MapTypeId.SATELLITE,
> >         navigationControl: true,
> >         scrollwheel: false,
> >         navigationControlOptions: {
> >             style: google.maps.NavigationControlStyle.DEFAULT,
> >             position: google.maps.ControlPosition.RIGHT
> >         },
> >         tilesloaded : function(){
> >             alert("hi");
> >             customiseLargeMapControl();
> >         }
> >     };
> >     var map = new
> > google.maps.Map(document.getElementById("map_canvas"),
> >         myOptions);
>
> > Any tips?- Hide quoted text -
>
> - Show quoted text -

Martin

unread,
Sep 28, 2010, 12:29:29 PM9/28/10
to Google Maps JavaScript API v3
Try this:

var latlng = new google.maps.LatLng(32.505338, -98.349152);
var myOptions = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE,
navigationControl: true,
scrollwheel: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.DEFAULT,
position: google.maps.ControlPosition.RIGHT
};
var map = new
google.maps.Map(document.getElementById("map_canvas"),
myOptions);

GEvent.addListener(map, 'tilesloaded', function(){
alert('hi');
customiseLargeMapControl();
});

http://code.google.com/apis/maps/documentation/javascript/reference.html#event

You might also look at the Map 'idle' event but i don't think it will
do what you want.
The tilesloaded event apparently fires once all the map tiles have
been retrieved from the server but BEFORE they have been rendered on
the map.

Martin.

Luke Mahé

unread,
Sep 28, 2010, 5:10:51 PM9/28/10
to google-map...@googlegroups.com
GEvent.addListener(map, 'tilesloaded', function(){
       alert('hi');
       customiseLargeMapControl();
});

should be

google.maps.event.addListener(map, 'tilesloaded', function(){

       alert('hi');
       customiseLargeMapControl();
});

-- Luke

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Martin

unread,
Sep 28, 2010, 5:28:22 PM9/28/10
to Google Maps JavaScript API v3
Ooops i stand corrected - v3 it is.

In fact if you don't want the callback to execute more than once you
might try:

google.maps.event.addListenerOnce(map, 'tilesloaded', function(){
Martin.


On 28 Sep, 22:10, Luke Mahé <lu...@google.com> wrote:
> GEvent.addListener(map, 'tilesloaded', function(){
>        alert('hi');
>        customiseLargeMapControl();
>
> });
>
> should be
>
> google.maps.event.addListener(map, 'tilesloaded', function(){
>        alert('hi');
>        customiseLargeMapControl();
>
> });
>
> -- Luke
>
> On Wed, Sep 29, 2010 at 2:29 AM, Martin <warwo...@gmail.com> wrote:
> > Try this:
>
> > var latlng = new google.maps.LatLng(32.505338, -98.349152);
> > var myOptions = {
> > zoom: 4,
> > center: latlng,
> > mapTypeId: google.maps.MapTypeId.SATELLITE,
> > navigationControl: true,
> > scrollwheel: false,
> > navigationControlOptions: {
> > style: google.maps.NavigationControlStyle.DEFAULT,
> > position: google.maps.ControlPosition.RIGHT
> > };
> > var map = new
> > google.maps.Map(document.getElementById("map_canvas"),
> > myOptions);
>
> > GEvent.addListener(map, 'tilesloaded', function(){
> >        alert('hi');
> >        customiseLargeMapControl();
> > });
>
> >http://code.google.com/apis/maps/documentation/javascript/reference.h...
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages