You need to use a chain of window.setTimeout() statements, where the
execution of each statement sets up the next, but this is not a Google
Maps API issue. It's just basic Javascript.
// A function to create the marker and set up the event window
function createMarker(point,name,html,icontype) {
var marker = new GMarker(point,dialIcons[icontype]);
GEvent.addListener(marker, "click", function() {
map.setCenter(new GLatLng( 52.67,-2.67),9,G_SATELLITE_MAP);
setTimeout("map.panTo(point)", 100);
for (var i = 9; i < 18; i++) {
setTimeout("map.zoomIn()",50);
}
marker.openInfoWindowHtml(html);
});
// save the info we need to use later for for the side_bar
gmarkers[i] = marker;
htmls[i] = html;
// ======= Add the sidebar entry to one of the sidebars =====
side_html = '<a href="javascript:myclick(' + i + ')">' + name
+ '</a><br>';
sidebar_html[Math.floor(i/num_markers)] += side_html;
// ==========================================================
i++;
return marker;
}
My intention is to zoomIn from 9 to 18 smoothly before opening the
InfoWindow.
It doesn 't appear to work correctly. I'm sure I'm missing some newbie
point! .Any suggestions gratefully received.
Phil
On 20 Aug, 09:58, marcelo <marcelo...@hotmail.com> wrote:
> You need to use a chain of window.setTimeout() statements, where the
> execution of each statement sets up the next, but this is not a Google
> Maps API issue. It's just basic Javascript.
In any case, you need a *chain* of setTimeout() statements, meaning
that each one launches when the previous one completed, but that is
pure javascript and outside the scope of this group.
In any case, I doubt it will all look as smoooth as you mght expect.
On 23 elo, 21:09, marcelo <marcelo...@hotmail.com> wrote:
> In any case, you need a *chain* of setTimeout() statements, meaning
> that each one launches when the previous one completed
Exactly. A simple way to construct the chain is to use 'zoomend' event
listener to trigger the new setTimeout(). The event returns old and
new zoomlevels as parameters which are handy for an if() limiter.
Using setInterval() might be even easier.
> In any case, I doubt it will all look as smoooth as you mght expect.
I agree with your doubt. I tried it once with terrible results. First
of all
setTimeout("map.zoomIn()",50) is much too quick. I don't get the tiles
so fast and there is no sense to make a page that works only with a
100M connection. It should be more than 500 milliseconds.
You have to use continuous zoom if you even dream to get a smooth
result, but actually that is too fast.
Start with something like
GEvent.addListener(map,'zoomend',function(oldZ,newZ){
var delay = setTimeout("map.zoomIn(null,null,true)",500);
if(newZ > 16) delay = null;
});
with continuous zoom enabled. And you see that continuous zoom stops
waiting on every step but still there are tiles missing all the time.
Even cpu doesn't like it. It goes hot.
I can see one solution. Try to hack the speed control of the
continuous zoom and turn it slower, somewhere around two seconds per
zoomlevel step.
I have added the enableContinuousZoom statement and changed the
setTimeouts in the zoomIn() loop as you suggested.
I have tried to follow your posts but I am in uncharted waters. I
don't understand the "zoomend" listener and this statement: var delay
= setTimeout("map.zoomIn(null,null,true)",500); Are there parameters
to zoomIn()?
Using my code in the link, I see only the first and the last zoom
level and, in between, the InfoWindow
Again, your help is appreciated,
Phil
On 23 Aug, 23:57, Esa <esa.ilm...@gmail.com> wrote:
> On 23 elo, 21:09, marcelo <marcelo...@hotmail.com> wrote:
> > In any case, you need a *chain* of setTimeout() statements, meaning
> > that each one launches when the previous one completed
> Exactly. A simple way to construct the chain is to use 'zoomend' event
> listener to trigger the new setTimeout(). The event returns old and
> new zoomlevels as parameters which are handy for an if() limiter.
> Using setInterval() might be even easier.
> > In any case, I doubt it will all look as smoooth as you mght expect.
> I agree with your doubt. I tried it once with terrible results. First
> of all
> setTimeout("map.zoomIn()",50) is much too quick. I don't get the tiles
> so fast and there is no sense to make a page that works only with a
> 100M connection. It should be more than 500 milliseconds.
> You have to use continuous zoom if you even dream to get a smooth
> result, but actually that is too fast.
> Start with something like
> GEvent.addListener(map,'zoomend',function(oldZ,newZ){
> var delay = setTimeout("map.zoomIn(null,null,true)",500);
> if(newZ > 16) delay = null;});
> with continuous zoom enabled. And you see that continuous zoom stops
> waiting on every step but still there are tiles missing all the time.
> Even cpu doesn't like it. It goes hot.
> I can see one solution. Try to hack the speed control of the
> continuous zoom and turn it slower, somewhere around two seconds per
> zoomlevel step.
Copy/paste the code to your page so that you can crank the timeout
value.
> I have tried to follow your posts but I am in uncharted waters. I
> don't understand the "zoomend" listener and this statement: var delay
> = setTimeout("map.zoomIn(null,null,true)",500); Are there parameters
> to zoomIn()?
zoomIn() parameters are undocumented but you have to set the third
parameter to get animated continuous zoomIn.
GEvent 'zoomend' listener is constructed to trigger the next timeouted
zoomIn() when the previous zooming ends.
var delay is the variable name for the setTimeout() function so that
we can destroy it and stop the process by
delay = null;
I still have to clear a few things about timing of the loop.
If you have no continuous zoom you have to set some timeout because
'zoomend' comes immediately after zoomIn() is triggered.
Continuous zoom gives you around 500 ms of timeout by itself. The
timeOut value of our loop is the time how long the code waits after
continuous zoom animation is finished. And after that wait time a new
zoomIn() is triggered. So you can set the value to zero with
continuous zoom. Zero is the value for smooth animation. But in
practice the map tiles are not loaded that fast.
I copied your demo page, animPan.htm, into my website and altered the
timeOut to 1500, which allows me to see the zoomIn() to step steadily
from 1 to 16 on the LargeControl..
At the zoomIn() at 9, ie the first iteration, the infoWindow appears.
No more steps appear in the LargeControl until the last (16) iteration
when the script continues normally.
I presume that my problem is to do with the infoWindow. Do I need to
create a Listener for the InfoControl and ,if so ,how do I do this? .
Or it is something else in my code?
> I still have to clear a few things about timing of the loop.
> If you have no continuous zoom you have to set some timeout because
> 'zoomend' comes immediately after zoomIn() is triggered.
> Continuous zoom gives you around 500 ms of timeout by itself. The
> timeOut value of our loop is the time how long the code waits after
> continuous zoom animation is finished. And after that wait time a new
> zoomIn() is triggered. So you can set the value to zero with
> continuous zoom. Zero is the value for smooth animation. But in
> practice the map tiles are not loaded that fast.