06-08-2011 07:47 AM
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 ![]()
tq
06-08-2011 08:12 AM
06-14-2011 10:55 PM
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
// 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.
06-15-2011 12:14 AM
There's a good tutorial video at gotoandlearn on Multi Touch Gesture.
03-05-2013 09:24 AM
im the user for blackberry torch 9860,you have shown the codes but i dont know where i have to type it...
03-05-2013 10:16 AM
03-05-2013 10:22 AM
03-05-2013 10:46 AM