Quantcast

weird zoom behavior mouse wheel vs double click

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

weird zoom behavior mouse wheel vs double click

Alessandro Ferrucci-3
Hello,
I have the following very simple map initialization code for
OpenLayers with google maps:

  var map;
            var projectionWGS84 = new OpenLayers.Projection("EPSG:4326");
            var projectionMercator = new OpenLayers.Projection("EPSG:900913");
            // Avoid pink error tiles
            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
            OpenLayers.Util.onImageLoadErrorColor = "transparent";

            function init(){

                var options = {
                    projection: new OpenLayers.Projection("EPSG:900913"),
                    displayProjection: new OpenLayers.Projection("EPSG:4326"),
                    units: "m",
                    numZoomLevels: 20,
                    maxResolution: 156543.0339,
                    maxExtent: new OpenLayers.Bounds(-20037508,
-20037508,20037508, 20037508),
                    controls:[
                            new OpenLayers.Control.Navigation(),
                            new OpenLayers.Control.ArgParser(),
                            new OpenLayers.Control.Attribution(),
                            new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15) }),
                            new OpenLayers.Control.Navigation(),
                            new OpenLayers.Control.Scale($('scale')),
                            new OpenLayers.Control.LayerSwitcher(),
                            new OpenLayers.Control.MousePosition(),
                            new OpenLayers.Control.Permalink()
                        ]

            };

                map = new OpenLayers.Map('map',options);
                var googleStreetLayer = new
OpenLayers.Layer.Google("Google Street", {'sphericalMercator':true} );
                map.addLayers([googleStreetLayer]);
                map.addControl(new OpenLayers.Control.LayerSwitcher());
                map.addControl(new OpenLayers.Control.MousePosition());
                var USABounds=new
OpenLayers.Bounds(-124.731,24.956,-66.97,49.372);
                USABounds.transform(projectionWGS84,map.getProjectionObject());
              //  map.zoomToMaxExtent();
                map.zoomToExtent(USABounds);
            }

This works fine however, the zoom behavior is weird when I zoom in and
out using the mouse wheel.
When I double click on the map the map zooms in 1 tick mark fine,
however when I use the mouse wheel to zoom in and out, it zooms 2
ticks at a time.

Has anyone ever encountered this behavior?  Any hints as to why it
would work as such?

I am using the following OpenLayers

<script src="http://openlayers.org/api/OpenLayers.js"
type="text/javascript"></script>

Thank you,
Alessandro Ferrucci
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: weird zoom behavior mouse wheel vs double click

Alessandro Ferrucci-3
DOH!

I've figured it out.... I had duplicate controls added to the map.
Here is the code that works fine with the extra controls removed.

Should have looked closer at the code before writing the question...
Thank you very much,
Alessandro Ferrucci

 var map;
            var projectionWGS84 = new OpenLayers.Projection("EPSG:4326");
            var projectionMercator = new OpenLayers.Projection("EPSG:900913");
            // Avoid pink error tiles
            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
            OpenLayers.Util.onImageLoadErrorColor = "transparent";

            function init(){

                var options = {
                    projection: new OpenLayers.Projection("EPSG:900913"),
                    displayProjection: new OpenLayers.Projection("EPSG:4326"),
                    units: "m",
                    numZoomLevels: 20,
                    maxResolution: 156543.0339,
                    maxExtent: new OpenLayers.Bounds(-20037508,
-20037508,20037508, 20037508),
                    controls:[
                            new OpenLayers.Control.Navigation(),
                            new OpenLayers.Control.ArgParser(),
                            new OpenLayers.Control.Attribution(),
                            new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15) }),
                        //    new OpenLayers.Control.Navigation(),
                            new OpenLayers.Control.Scale($('scale')),
                            new OpenLayers.Control.LayerSwitcher(),
                            new OpenLayers.Control.MousePosition(),
                            new OpenLayers.Control.Permalink()
                        ]

            };

                map = new OpenLayers.Map('map',options);
                var googleStreetLayer = new
OpenLayers.Layer.Google("Google Street", {'sphericalMercator':true} );
                map.addLayers([googleStreetLayer]);
           //     map.addControl(new OpenLayers.Control.LayerSwitcher());
//                map.addControl(new OpenLayers.Control.MousePosition());
                var USABounds=new
OpenLayers.Bounds(-124.731,24.956,-66.97,49.372);
                USABounds.transform(projectionWGS84,map.getProjectionObject());
              //  map.zoomToMaxExtent();
                map.zoomToExtent(USABounds);
            }

On Sun, Jul 24, 2011 at 1:06 PM, Alessandro Ferrucci
<[hidden email]> wrote:

> Hello,
> I have the following very simple map initialization code for
> OpenLayers with google maps:
>
>  var map;
>            var projectionWGS84 = new OpenLayers.Projection("EPSG:4326");
>            var projectionMercator = new OpenLayers.Projection("EPSG:900913");
>            // Avoid pink error tiles
>            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
>            OpenLayers.Util.onImageLoadErrorColor = "transparent";
>
>            function init(){
>
>                var options = {
>                    projection: new OpenLayers.Projection("EPSG:900913"),
>                    displayProjection: new OpenLayers.Projection("EPSG:4326"),
>                    units: "m",
>                    numZoomLevels: 20,
>                    maxResolution: 156543.0339,
>                    maxExtent: new OpenLayers.Bounds(-20037508,
> -20037508,20037508, 20037508),
>                    controls:[
>                            new OpenLayers.Control.Navigation(),
>                            new OpenLayers.Control.ArgParser(),
>                            new OpenLayers.Control.Attribution(),
>                            new OpenLayers.Control.PanZoomBar({
> position: new OpenLayers.Pixel(2, 15) }),
>                            new OpenLayers.Control.Navigation(),
>                            new OpenLayers.Control.Scale($('scale')),
>                            new OpenLayers.Control.LayerSwitcher(),
>                            new OpenLayers.Control.MousePosition(),
>                            new OpenLayers.Control.Permalink()
>                        ]
>
>            };
>
>                map = new OpenLayers.Map('map',options);
>                var googleStreetLayer = new
> OpenLayers.Layer.Google("Google Street", {'sphericalMercator':true} );
>                map.addLayers([googleStreetLayer]);
>                map.addControl(new OpenLayers.Control.LayerSwitcher());
>                map.addControl(new OpenLayers.Control.MousePosition());
>                var USABounds=new
> OpenLayers.Bounds(-124.731,24.956,-66.97,49.372);
>                USABounds.transform(projectionWGS84,map.getProjectionObject());
>              //  map.zoomToMaxExtent();
>                map.zoomToExtent(USABounds);
>            }
>
> This works fine however, the zoom behavior is weird when I zoom in and
> out using the mouse wheel.
> When I double click on the map the map zooms in 1 tick mark fine,
> however when I use the mouse wheel to zoom in and out, it zooms 2
> ticks at a time.
>
> Has anyone ever encountered this behavior?  Any hints as to why it
> would work as such?
>
> I am using the following OpenLayers
>
> <script src="http://openlayers.org/api/OpenLayers.js"
> type="text/javascript"></script>
>
> Thank you,
> Alessandro Ferrucci
>



--
Signed,
Alessandro Ferrucci
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

OpenLayers 2.10 Beginner's Guide - Useful?

Arnie Shore
In reply to this post by Alessandro Ferrucci-3
I'll appreciate anyone's opinion on subject publication, esp for
possible use by a semi-noob here, who's put up one OSM/OL map so far,
and who speaks JS OK.

AS
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OpenLayers 2.10 Beginner's Guide - Useful?

rgreenwood
Arnie,

The book doesn't go into great depth but does provide a good, even,
well organized coverage of all of the high level components of
OpenLayers. I wouldn't rate it as "essential reading" as you can get
the same information out of the many OpenLayers examples. But it's
great for a beginner and bound to fill in some cracks in the
intermediate OpenLayers user's knowledge.

Rich


On Sun, Jul 24, 2011 at 3:39 PM, Arnie Shore <[hidden email]> wrote:

> I'll appreciate anyone's opinion on subject publication, esp for possible
> use by a semi-noob here, who's put up one OSM/OL map so far, and who speaks
> JS OK.
>
> AS
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



--
Richard Greenwood
[hidden email]
www.greenwoodmap.com
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OpenLayers 2.10 Beginner's Guide - Useful?

Nizzok
I agree, it's a good overview of some of the basics of OL and as Rich said goes into the high-level components. Like a lot of programming books it provides you the basics, with one example application with the 'dots-connected,' showing you how to build a Flickr/OL mashup. If you're a noob, you'll definitely learn from the book, but it's by no means an end-all, be-all. 

For web-mapping concepts, I highly recommend 'Mapscripting 101', which although it focuses mostly on Google and Yahoo (now defunct) mapping APIs it does a really good job of introducing concepts that can easily be transferred to OL once you wrap you're head around them. It also introduces the Mapstraction JS, which to some extent works with OL, but I think it's useful for introducing a lot of web-mapping concepts which aren't spelled out elsewhere (i.e. geocoding, creating/using geodatabases, geolocation, etc). It doesn't cover all of these subjects in great detail, but it's more oriented on web-mapping concepts, rather than getting far under the hood with one or another library...

On Mon, Jul 25, 2011 at 8:39 AM, Richard Greenwood <[hidden email]> wrote:
Arnie,

The book doesn't go into great depth but does provide a good, even,
well organized coverage of all of the high level components of
OpenLayers. I wouldn't rate it as "essential reading" as you can get
the same information out of the many OpenLayers examples. But it's
great for a beginner and bound to fill in some cracks in the
intermediate OpenLayers user's knowledge.

Rich


On Sun, Jul 24, 2011 at 3:39 PM, Arnie Shore <[hidden email]> wrote:
> I'll appreciate anyone's opinion on subject publication, esp for possible
> use by a semi-noob here, who's put up one OSM/OL map so far, and who speaks
> JS OK.
>
> AS
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



--
Richard Greenwood
[hidden email]
www.greenwoodmap.com
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Loading...