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 8239321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:06:28+00:00 2026-06-07T20:06:28+00:00

I searched for two hours but only found draw Line, i want get direction

  • 0

I searched for two hours but only found draw Line, i want get direction as this form Click here! I have ten point and when i click the point i want to show direction from my location to the point.
My code look:

package de.vogella.android.locationapi.maps;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

   import com.google.android.maps.GeoPoint;
   import com.google.android.maps.MapActivity;
   import com.google.android.maps.MapController;
   import com.google.android.maps.MapView;
   import com.google.android.maps.MyLocationOverlay;
   import com.google.android.maps.OverlayItem;
   import com.google.android.maps.Projection;

    public class ShowMapActivity extends MapActivity {

private MapController mapController;
private MapView mapView;
private LocationManager locationManager;
private MyOverlays itemizedoverlay,itemizedoverlay_central;
private MyLocationOverlay myLocationOverlay;
private String nameOfOffice_AZ[];
private String addressOfOffice_AZ[];
private String phoneOfOffice_AZ[];

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.main); // bind the layout to the activity

    // Configure the Map
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    Projection projection = mapView.getProjection();

    nameOfOffice_AZ= getResources().getStringArray(R.array.NamesOFObject_AZ);
    addressOfOffice_AZ = getResources().getStringArray(R.array.AddressOfOffice_AZ);
    phoneOfOffice_AZ = getResources().getStringArray(R.array.PhoneOfOffice_AZ);


    mapController = mapView.getController();
    mapController.setZoom(16); // Zoon 1 is world view
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
            0, new GeoUpdateHandler());

    myLocationOverlay = new MyLocationOverlay(this, mapView);
    mapView.getOverlays().add(myLocationOverlay);

    myLocationOverlay.runOnFirstFix(new Runnable() {
        public void run() {
            mapView.getController().animateTo(myLocationOverlay.getMyLocation());
        }
    });

    Drawable drawable = this.getResources().getDrawable(R.drawable.office_icon);
    Drawable drawable_central = this.getResources().getDrawable(R.drawable.central_office);



    itemizedoverlay = new MyOverlays(this, drawable);
    itemizedoverlay_central = new MyOverlays(this, drawable_central);

    createMarker();
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

public class GeoUpdateHandler implements LocationListener {

    @Override
    public void onLocationChanged(Location location) {
        int lat = (int) (location.getLatitude() * 1E6);
        int lng = (int) (location.getLongitude() * 1E6);
        GeoPoint point = new GeoPoint(lat, lng);
        createMarker();
        mapController.animateTo(point); // mapController.setCenter(point);

    }

    @Override
    public void onProviderDisabled(String provider) {
    }

    @Override
    public void onProviderEnabled(String provider) {
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
    }
}

private void createMarker() {
    //CENTRAL OFFICE
    GeoPoint p_central = new GeoPoint((int)(40.38292884084829 * 1e6),(int)(49.84223246574 * 1e6));
    OverlayItem overlayitem = new OverlayItem(p_central, nameOfOffice_AZ[0] ,addressOfOffice_AZ[0]+"\n"+phoneOfOffice_AZ[0] );
    itemizedoverlay_central.addOverlay(overlayitem);
    mapView.getOverlays().add(itemizedoverlay_central);
    //END CENTRALL OFFICE


    GeoPoint p = new GeoPoint((int)(40.376455916943236 * 1e6),(int)(49.84803676605224 * 1e6));
    overlayitem = new OverlayItem(p, nameOfOffice_AZ[0] ,addressOfOffice_AZ[0]+"\n"+phoneOfOffice_AZ[0] );
    itemizedoverlay.addOverlay(overlayitem);

        mapView.getOverlays().add(itemizedoverlay);

}

@Override
protected void onResume() {
    super.onResume();
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();
}

@Override
protected void onPause() {
    super.onPause();
    myLocationOverlay.disableMyLocation();
    myLocationOverlay.disableCompass();
}

}
and MyOverlays.java

package de.vogella.android.locationapi.maps;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
 import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

 public class MyOverlays extends ItemizedOverlay<OverlayItem> {

private static int maxNum = 5;
private OverlayItem overlays[] = new OverlayItem[maxNum];
private int index = 0;
private boolean full = false;
private Context mContext;
private OverlayItem previousoverlay;

public MyOverlays(Context context, Drawable defaultMarker) {
    super(boundCenterBottom(defaultMarker));
    this.mContext = context;
}

private ArrayList< OverlayItem > mOverlays = new ArrayList< OverlayItem >();





public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}
public void name()  {

}
@Override
protected OverlayItem createItem(int i) {
    return mOverlays.get(i);
}

@Override
public int size() {
    return mOverlays.size();
}

@Override
protected boolean onTap(int i) {
    //when you tap on the marker this will show the informations provided by you when    you create in the 
    //main class the OverlayItem
   OverlayItem item = mOverlays.get(i);

    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setInverseBackgroundForced(true);
    dialog.setTitle(item.getTitle());
    dialog.setMessage(item.getSnippet());

    dialog.setCancelable(true);
    dialog.setPositiveButton("Go To", new OkOnClickListener());
   /// dialog.setNegativeButton("No, no", new CancelOnClickListener());
    dialog.show();
//  nese bax = new nese();
//  bax.oldu(mContext);
    return true;
}
private final class CancelOnClickListener implements
DialogInterface.OnClickListener {
    public void onClick(DialogInterface dialog, int which) {
        Toast.makeText(mContext, "You clicked yes", Toast.LENGTH_LONG)
                .show();
    }
    }

    private final class OkOnClickListener implements
    DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
    //Toast.makeText(mContext, "You clicked no", Toast.LENGTH_LONG).show();
}

}


    public class RoutePath extends MapActivity { 
/** Called when the activity is first created. */ 

MapView mapView; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 

MapView mapView = (MapView) findViewById(R.id.mapview); 
double src_lat = 25.04202; // the testing source 
double src_long = 121.534761; 
double dest_lat = 25.05202; // the testing destination 
double dest_long = 121.554761; 
GeoPoint srcGeoPoint = new GeoPoint((int) (src_lat * 1E6), 
(int) (src_long * 1E6)); 
GeoPoint destGeoPoint = new GeoPoint((int) (dest_lat * 1E6), 
(int) (dest_long * 1E6)); 

DrawPath(srcGeoPoint, destGeoPoint, Color.GREEN, mapView); 

mapView.getController().animateTo(srcGeoPoint); 
mapView.getController().setZoom(15); 

} 

@Override 
protected boolean isRouteDisplayed() { 
// TODO Auto-generated method stub 
return false; 
} 

private void DrawPath(GeoPoint src, GeoPoint dest, int color, 
MapView mMapView01) { 

// code in section 2.2 

} 

}

}

  • 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-06-07T20:06:31+00:00Added an answer on June 7, 2026 at 8:06 pm

    Less efforts on search..

    Anyway look at Google Driving Directions – MapView overlayed Also The Google Directions API

    and using intent

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?saddr=xx.xx,xx.xx&daddr=xx.xx,xx.xx"));
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Searched a lot about this problem but never found a answer, that solved it.
i searched for hours for a way to solve my problem but didn't get
I've searched online about this problem and I've found two ways so far: while
I've searched for an answer to this and I've come up with only two
ok, i have searched for this in the past two hours with results that
I have tried everything, searched the net for two hours or even more and
Searched around on SO for an answer. Found some interesting stuff but I am
I've searched for two days trying to find a solution to this. My problem
I searched for a long time, but I don't manage to retrieve two related
I searched the site but I could not find any solution to this problem.

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.