Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:20:31+00:00 2026-05-27T13:20:31+00:00

I’m try to do pinch zoom sample.but itz not working.I think the issue is

  • 0

I’m try to do pinch zoom sample.but itz not working.I think the issue is activity class can’t identify the items in xml file.

ERROR Description mapview cannot be resolved or is not a field.

My code as below

package pinchZoom.com;
import android.R;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.nikkoaiello.mobile.android.PinchMapView;

public class PinchZoomActivity extends MapActivity
{

PinchMapView view;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mapview);
    view = (PinchMapView) findViewById(R.id.Map);
}

protected boolean isRouteDisplayed() {
    return false;
}

//////////////////////////xml file///////////////////////////////////////////////

  <?xml version="1.0" encoding="utf-8"?>

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:isScrollContainer="true"

    >

   <com.nikkoaiello.mobile.android.PinchMapView

        android:id="@+id/Map"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:clickable="true"

        android:apiKey="***MY API KEY***"

   />


   </RelativeLayout>

Could someone please tell me the way to fix this? If you have any worked through examples, that would be a real help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:20:31+00:00Added an answer on May 27, 2026 at 1:20 pm
    // These matrices will be used to scale points of the image
        Matrix matrix = new Matrix();
        Matrix savedMatrix = new Matrix();
    
        // The 3 states (events) which the user is trying to perform
        static final int NONE = 0;
        static final int DRAG = 1;
        static final int ZOOM = 2;
        int mode = NONE;
    
        // these PointF objects are used to record the point(s) the user is touching
        PointF start = new PointF();
        PointF mid = new PointF();
        float oldDist = 1f;
    
        ImageView sampleImageView;
    
    @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sample);
    
         sampleImageView = (ImageView) findViewById(R.id.sampleImageView);
    
        sampleImageView.setOnTouchListener(new OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
            ImageView view = (ImageView) v;
                  view.setScaleType(ImageView.ScaleType.MATRIX);
    
            // Handle touch events here...
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
    
            case MotionEvent.ACTION_DOWN:
                savedMatrix.set(matrix);
                start.set(event.getX(), event.getY());
                mode = DRAG;
    
                break;
    
            case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
    
                if (oldDist > 10f) {
                savedMatrix.set(matrix);
                midPoint(mid, event);
                mode = ZOOM;
                }
    
                break;
    
            case MotionEvent.ACTION_UP:
    
            case MotionEvent.ACTION_POINTER_UP:
                mode = NONE;
    
                break;
    
            case MotionEvent.ACTION_MOVE:
                if (mode == DRAG) {
                // ...
                matrix.set(savedMatrix);
    
                float postTranslateX = event.getX() - start.x;
                float postTranslateY = event.getY() - start.y;
    
                matrix.postTranslate(postTranslateX, postTranslateY);
    
                } else if (mode == ZOOM) {
                float newDist = spacing(event);
    
                if (newDist > 10f) {
                    matrix.set(savedMatrix);
                    float scale = newDist / oldDist;
                    matrix.postScale(scale, scale, mid.x, mid.y);
                }
                }
    
                break;
            }
    
            view.setImageMatrix(matrix);
    
            return true; // indicate event was handled
    
            }
        });
        }
    
        /**
         * Checks the spacing between the two fingers on touch.
         * 
         * @param event
         *            the MotionEvent
         * @return float
         */
        private float spacing(MotionEvent event) {
           float x = event.getX(0) - event.getX(1);
           float y = event.getY(0) - event.getY(1);
    
           return FloatMath.sqrt(x * x + y * y);
        }
    
        /**
         * Calculates the midpoint between the two fingers.
         * 
         * @param point
         *            the PointF object,
         * @param event
         *            the MotionEvent
         */
        private void midPoint(PointF point, MotionEvent event) {
           float x = event.getX(0) + event.getX(1);
           float y = event.getY(0) + event.getY(1);
           point.set(x / 2, y / 2);
        }
    

    Please try this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.