0

I am using the Following code....

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?saddr="
+ 35.63508 + "," + -88.83184 + "&daddr="+ destinationLatitude + ","+ destinationLongitude));

How can i Zoom to source Point while showing Directions in Google Maps in Android.

Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66

1 Answers1

0

I use the following code to zoom to a particular point on mapview

In your MapActivity call zoomToMyLocation() and in that function you can specify the latitude and longitude of source point .Here we use getController to setzoom();

private void zoomToMyLocation() {
            GeoPoint myLocationGeoPoint = getgetPoint(29.0167, 77.3833);

            if (myLocationGeoPoint != null) {

                    mapView.getController().animateTo(myLocationGeoPoint);
                    mapView.getController().setZoom(10);

            } else {
                Toast.makeText(this, "Cannot determine location",
                 Toast.LENGTH_SHORT).show();
            }
        }

        private GeoPoint getPoint(double lat, double lon) {
            return (new GeoPoint((int) (lat * 1000000.0), (int) (lon * 1000000.0)));
        }

Related Link:

Zooming and animating to point mapview android

EDIT1

Refer to this link if you are only using a intent instead of mapview activity Android - How to launch Google map intent in android app with certain location, zoom level and marker

EDIT2

Since intent lets you specify only one point ,you can zoom to only one point.AFAIK you will have to create a MapActivity ,mapview's map controller lets you zoom over a span using

mapView.getController().zoomToSpan(lat,lon ,lat1,lon1);
Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
  • I am not extending from MapActivity as there is no major Functionality,only i need to show the Direction betwwen two points and zoom to source point. Directly i am passing the points through Intent. – Satyasarathi Jul 22 '13 at 06:12
  • firstly update your question and correctly state your problem and explain what you have used with code .So that people help you .Your question is highly ambigious – Rachita Nanda Jul 22 '13 at 06:14
  • I need to Display the Driving Direction between two GeoPoints and after Displaying the Direction i need to zoom into the Source Point automatically. For that I have used below Code Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + 35.63508 + "," + -88.83184 + "&daddr=" + destinationLatitude + "," + destinationLongitude+"&z=16")); – Satyasarathi Jul 22 '13 at 06:19
  • Thanks for your post Rachita ..I tried that Link.It is only showing one point at a time. It zooms to that point also nicely but i am unable to show the direction.So i guess it may not work with 2 GeoPoints. – Satyasarathi Jul 22 '13 at 07:26
  • Since intent lets you specify only one point ,you can zoom to only one point.AFAIK you will have to create a MapActivity ,mapview's map controller lets you zoom over a span using mapView.getController().zoomToSpan(lat,lon ,lat1,lon1); – Rachita Nanda Jul 22 '13 at 07:41
  • Finally Got Solution From Here.. https://doc-14-4s-docs.googleusercontent.com/docs/securesc/ods7129k6hp9bjn35rdl2q8tn44p4il6/uc2sn3pnhgcqkbfmtig5epoa8f591qnl/1374552000000/13072187865119303026/04259012655072954194/0B0MdROeR0jbvWVVNUV9jbk1OeEE?e=download&h=14614192385467331438&nonce=gbkbcgrt60o9s&user=04259012655072954194&hash=tp0sks8gkam8a0s4alcms1rt4hte42os Thanks For all your efforts.. – Satyasarathi Jul 23 '13 at 06:35