It is great to see better "Scroll to Zoom" support in official GMap API and blog. I have been implementing and advertising this feature even before Google does its own. Google makes its far better version later on. Cheers!
It is essential to capture and stop further propagation of the scroll event once it is implying change inside the map widget. For example, when I am reading on the google map api blog, I find that rolling the wheels results two changes. The web page is scrolled. The map responds later. That is somehow confusing.
I am quite sure that a piece of java-script is enough to solve the problem in IE, FF, Op, etc. It would be nice if the Official GMap API Blog suggest its own. At lease, warn people not to make too long pages with the Map /w "Scroll to Zoom" feature.
> It is great to see better "Scroll to Zoom" support in official GMap > API and blog. > I have been implementing and advertising this feature even before > Google does its own. > Google makes its far better version later on. Cheers!
> It is essential to capture and stop further propagation of the scroll > event once it is implying change inside the map widget. For example, > when I am reading on the google map api blog, I find that rolling the > wheels results two changes. The web page is scrolled. The map responds > later. That is somehow confusing.
> I am quite sure that a piece of java-script is enough to solve the > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > Blog suggest its own. At lease, warn people not to make too long pages > with the Map /w "Scroll to Zoom" feature.
This is correct code: (previous has errors) if (map.addEventListener) map.addEventListener("DOMMouseScroll", function(e) { e.preventDefault(); }, false); else if (map.attachEvent) map.attachEvent("onmousewheel", function() { event.returnValue = false; });
> On Apr 18, 9:25 pm, "benc...@gmail.com" <benc...@gmail.com> wrote: > > It is great to see better "Scroll to Zoom" support in official GMap > > API and blog. > > I have been implementing and advertising this feature even before > > Google does its own. > > Google makes its far better version later on. Cheers!
> > It is essential to capture and stop further propagation of the scroll > > event once it is implying change inside the map widget. For example, > > when I am reading on the google map api blog, I find that rolling the > > wheels results two changes. The web page is scrolled. The map responds > > later. That is somehow confusing.
> > I am quite sure that a piece of java-script is enough to solve the > > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > > Blog suggest its own. At lease, warn people not to make too long pages > > with the Map /w "Scroll to Zoom" feature.
Previous code won't work for me as well. I have to use: GEvent.addDomListener(map.getContainer(), "DOMMouseScroll", function(oEvent) { if (oEvent.preventDefault) oEvent.preventDefault(); });
> > On Apr 18, 9:25 pm, "benc...@gmail.com" <benc...@gmail.com> wrote: > > > It is great to see better "Scroll to Zoom" support in official GMap > > > API and blog. > > > I have been implementing and advertising this feature even before > > > Google does its own. > > > Google makes its far better version later on. Cheers!
> > > It is essential to capture and stop further propagation of the scroll > > > event once it is implying change inside the map widget. For example, > > > when I am reading on the google map api blog, I find that rolling the > > > wheels results two changes. The web page is scrolled. The map responds > > > later. That is somehow confusing.
> > > I am quite sure that a piece of java-script is enough to solve the > > > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > > > Blog suggest its own. At lease, warn people not to make too long pages > > > with the Map /w "Scroll to Zoom" feature.
My solution, which seems to work in Opera (9.20), IE (7) and Firefox (2):
//----- Stop page scrolling if wheel over map ---- function wheelevent(e) { if (!e) e = window.event; if (e.preventDefault) e.preventDefault(); e.returnValue = false; } GEvent.addDomListener(mapDiv, "DOMMouseScroll", wheelevent); mapDiv.onmousewheel = wheelevent;
mapDiv is the <div> element that the map is applied to.
Haven't managed to test IE6, as the scroll wheel doesn't seem to work in MS Virtual PC :(
I agree, have you noticed that the click and pan works with the scroll wheel on the mouse, so zooming in and pan becomes one. side enable mouse wheels also nudge the map like a stepping pan.
> It is great to see better "Scroll to Zoom" support in official GMap > API and blog. > I have been implementing and advertising this feature even before > Google does its own. > Google makes its far better version later on. Cheers!
> It is essential to capture and stop further propagation of the scroll > event once it is implying change inside the map widget. For example, > when I am reading on the google map api blog, I find that rolling the > wheels results two changes. The web page is scrolled. The map responds > later. That is somehow confusing.
> I am quite sure that a piece of java-script is enough to solve the > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > Blog suggest its own. At lease, warn people not to make too long pages > with the Map /w "Scroll to Zoom" feature.
I have noticed that you have also to modify the URL of the key: if you use v=2& the map will not load because the method map.enableScrollWheelZoom(); is not accepted. You have to use v=2.x& to make the whole thing work.
ciao pietro
On Apr 19, 3:25 am, "benc...@gmail.com" <benc...@gmail.com> wrote:
> It is great to see better "Scroll to Zoom" support in official GMap > API and blog. > I have been implementing and advertising this feature even before > Google does its own. > Google makes its far better version later on. Cheers!
> It is essential to capture and stop further propagation of the scroll > event once it is implying change inside the map widget. For example, > when I am reading on the google map api blog, I find that rolling the > wheels results two changes. The web page is scrolled. The map responds > later. That is somehow confusing.
> I am quite sure that a piece of java-script is enough to solve the > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > Blog suggest its own. At lease, warn people not to make too long pages > with the Map /w "Scroll to Zoom" feature.
<tomotomocacchiocacc...@gmail.com> wrote: > I have noticed that you have also to modify the URL of the key: if you > use v=2& the map will not load because the method > map.enableScrollWheelZoom(); is not accepted. You have to use > v=2.x& to make the whole thing work.
> ciao > pietro
> On Apr 19, 3:25 am, "benc...@gmail.com" <benc...@gmail.com> wrote:
> > It is great to see better "Scroll to Zoom" support in official GMap > > API and blog. > > I have been implementing and advertising this feature even before > > Google does its own. > > Google makes its far better version later on. Cheers!
> > It is essential to capture and stop further propagation of the scroll > > event once it is implying change inside the map widget. For example, > > when I am reading on the google map api blog, I find that rolling the > > wheels results two changes. The web page is scrolled. The map responds > > later. That is somehow confusing.
> > I am quite sure that a piece of java-script is enough to solve the > > problem in IE, FF, Op, etc. It would be nice if the Official GMap API > > Blog suggest its own. At lease, warn people not to make too long pages > > with the Map /w "Scroll to Zoom" feature.
Wow - if the Maps API developers find this to be "optimized" then I must be going crazy ... why exactly do you leave out three lines of code that simply prevent the default page scrolling behavior? I consider this to be on par with "it's not a bug, it's a feature" - two big things going on here:
1) absolutely NO ONE is going to notice a better scroll speed by leaving those lines out (preventing the default might actually make it faster, wouldn't you think?) and 2) everyone who actually has enough content to require page scrolls will have to look through the forum, add the code, test it out, etc. which only leads to wasted user time - isn't the API produced to give us simplicity so that us developers don't have to do it?!?
Personally, I'm disappointed by all of this - I mean, maybe I just don't understand what they're trying to do, but please explain if this actually makes sense to you.
There is another minor issue. The animated red corners overflow from the map container. That may slightly mess page layout in certain circuimtances. Overflow can be decayed by simple css: overflow:hidden. See with FF: http://esa.ilmari.googlepages.com/scrollzoom.htm
It can be seen that ScrollWheelZoom() is originally designed for full screen maps.
Thanks to everyone who have suggested ways to produce desirable scroll wheel zoom behavior for alternative website layouts. I'll talk with the engineers to see if we can work in some of the suggestions into the core code. If we can add in some of the suggestions without breaking maps.google.com or adding too many lines of code, then improvement should be feasible.
Thanks to Esa for the great page demonstrating the workarounds. - pamela
On Apr 19, 2:15 pm, Esa <esa.ilm...@gmail.com> wrote:
> There is another minor issue. The animated red corners overflow from > the map container. That may slightly mess page layout in certain > circuimtances. Overflow can be decayed by simple css: overflow:hidden. > See with FF:http://esa.ilmari.googlepages.com/scrollzoom.htm
> It can be seen that ScrollWheelZoom() is originally designed for full > screen maps.
On Apr 19, 10:26 am, krispy <cplum...@integrity-apps.com> wrote:
> Personally, I'm disappointed by all of this - I mean, maybe I just > don't understand what they're trying to do, but please explain if this > actually makes sense to you.
Did you read pamela's blog post? She says it's a feature! The API is "optimized" for this behavior (her own words) - so don't give me any pre-release notions here - it's on the official blog! I'm not some malcontent sitting around waiting to point fingers - I see it as official from the API developers and I don't want my production code to have to "fix" their stuff.
-krispy
On Apr 20, 10:02 am, Crescent Fresh <i.jay...@gmail.com> wrote:
> On Apr 19, 10:26 am, krispy <cplum...@integrity-apps.com> wrote:
> > Personally, I'm disappointed by all of this - I mean, maybe I just > > don't understand what they're trying to do, but please explain if this > > actually makes sense to you.
The blog post notes that the feature is optimized for maps.google.com currently. I've already begun talking with the engineers to see if we can add to the code to optimize it for a more general page layout. If we do, the changes will probably come out in a few weeks to a month.
Oftentimes, a feature isn't exactly what developers want when it's first released. We rely on developer feedback (like your own) to see how features can be made better for the developer community and the vast plethora of websites they create.
- pamela
On Apr 20, 7:08 am, krispy <cplum...@integrity-apps.com> wrote:
> Did you read pamela's blog post? She says it's a feature! The API is > "optimized" for this behavior (her own words) - so don't give me any > pre-release notions here - it's on the official blog! I'm not some > malcontent sitting around waiting to point fingers - I see it as > official from the API developers and I don't want my production code > to have to "fix" their stuff.
> -krispy
> On Apr 20, 10:02 am, Crescent Fresh <i.jay...@gmail.com> wrote:
> > On Apr 19, 10:26 am, krispy <cplum...@integrity-apps.com> wrote:
> > > Personally, I'm disappointed by all of this - I mean, maybe I just > > > don't understand what they're trying to do, but please explain if this > > > actually makes sense to you.
As the one of the starters in this issue, please let me ease Krispy's concern.
I have actually received feedbacks about possible breakage of default web page behavior when I implement "scroll to zoom" at the first time. Some people are just not aware that Google make a similar feature. But for the official google map, they are push their engineer to fix the Map widget within the browser frame height, for me, I take another way out.
Actually, to zoom by wheels in my later implementations, user ( and developers) have an option to activation zoom and pan by "Ctrl / Meta + Scroll".
So if you are going to have die hard standard lovers, give them a choice !
I can sure there is room to do so. And for me, a tradition console applications developer, finding the right key-map is gonna to be a lot of fun.
> The blog post notes that the feature is optimized for > maps.google.com currently. I've already begun talking with the > engineers to see if we can add to the code to optimize it for a more > general page layout. If we do, the changes will probably come out in a > few weeks to a month.
> Oftentimes, a feature isn't exactly what developers want when it's > first released. We rely on developer feedback (like your own) to see > how features can be made better for the developer community and the > vast plethora of websites they create.
> - pamela
> On Apr 20, 7:08 am, krispy <cplum...@integrity-apps.com> wrote:
> > Did you read pamela's blog post? She says it's a feature! The API is > > "optimized" for this behavior (her own words) - so don't give me any > > pre-release notions here - it's on the official blog! I'm not some > > malcontent sitting around waiting to point fingers - I see it as > > official from the API developers and I don't want my production code > > to have to "fix" their stuff.
> > > > Personally, I'm disappointed by all of this - I mean, maybe I just > > > > don't understand what they're trying to do, but please explain if this > > > > actually makes sense to you.