Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
zhack
Posts: 13
Registered: ‎01-18-2011
My Device: bold 9000

Pinch To Zoom - Google Map

any1 know how to do the pinch to zoom(multitouch) event like i've seen i "MapApp" application or latest "Poynt" app?

 

this thing bothering since i start making app :Angel:

 

tq

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Pinch To Zoom - Google Map

This forum has a search feature. Does searching for "pinch zoom", for example, give you useful results? There was an example posted just a few days ago.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
brentcameron
Posts: 110
Registered: ‎10-31-2010
My Device: Blackberry Torch 9800

Re: Pinch To Zoom - Google Map

Google doesn't really support this so you have to code it yourself.  The challenge is that the flash API is somewhat limited with respect to zoom capabilties (map.setZoom) in that it just goes up and down by a 1-16 scale.  You can use zoomIn/zoomOut to go up or down a level and it has the handy feature of centering the zoom at a specific lat/long (you should set this between midway between your pinch).  I've been fooling around with this with my application and have it sort of working (although I haven't yet had time to use zoomIn/zoomOut).  I've spent a grand total of about 60 minutes on this over the past month...  here's my code... it may give you something to work from.

 

 

        // Setup event listener for pinch to zoom
        map.addEventListener(TransformGestureEvent.GESTURE_ZOOM, pinchZoom);   


 

 

        // transform the pinch to zoom gesture into a zoom
        private function pinchZoom(pinchEvent:TransformGestureEvent):void
        {
            // Wait for the gesture to end before setting the zoom
            switch (pinchEvent.phase)
            {
                case GesturePhase.BEGIN:
                {
                    this.myScaleX = pinchEvent.scaleX;
                    this.myScaleY = pinchEvent.scaleY;
                    break;
                }
                   
                case GesturePhase.UPDATE:
                {
                    this.myScaleX *= pinchEvent.scaleX;
                    this.myScaleY *= pinchEvent.scaleY;
                    break;
                }
                   
                case GesturePhase.END:
                {
           
                    this.myScaleX *= pinchEvent.scaleX;
                    this.myScaleY *= pinchEvent.scaleY;
                   
                    // Get the old map center
            //        mapCentre = this.map.getCenter();
                       
                    // now translate into a maps zoom level       
                    if ( this.myScaleX < 1.0 )
                    {
                        this.myScaleX = this.map.getZoom() - (1/this.myScaleX);
                        this.map.setZoom( this.myScaleX, true );
                    }
                    else if ( this.myScaleX > 1.0 )
                    {
                        this.myScaleX += this.map.getZoom();
                        this.map.setZoom( this.myScaleX, true );
                    }
                   
                    // reset the old centre of the map
        //            map.setCenter(mapCentre);
                   
                }
            }
       }
    

Right now it zooms from the centre of the map which is clearly wrong and I think using zoomIn/zoomOut with the location centred between the pinch locations is what's necessary but I haven't had time to try it.  Good luck.

Best regards,

Brent

If you found my post helpful, please thank me with a Kudo. Thanks!
Developer
XoomMan
Posts: 128
Registered: ‎03-18-2011
My Device: PlayBook

Re: Pinch To Zoom - Google Map

There's a good tutorial video at gotoandlearn on Multi Touch Gesture.

New Contributor
hariprasath
Posts: 9
Registered: ‎02-04-2013
My Device: blackberry torch 9860

Re: Pinch To Zoom - Google Map

im the user for blackberry torch 9860,you have shown the codes but i dont know where i have to type it...

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Pinch To Zoom - Google Map

Think you are on the wrong forum. This is a development forum for Adobe AIR.
New Contributor
hariprasath
Posts: 9
Registered: ‎02-04-2013
My Device: blackberry torch 9860

Re: Pinch To Zoom - Google Map

So do I install adobe air and make changes in it
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Pinch To Zoom - Google Map

Adobe AIR comes with BB10 and PlayBook devices. You cannot install Adobe AIR on BBOS devices.