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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:42:02+00:00 2026-06-15T02:42:02+00:00

I’ve created my own custom map to show my current location and multiple points

  • 0

I’ve created my own custom map to show my current location and multiple points on map. it works fine,but now i would like to show a route from my current location to every point on the map.Can you give me some suggestions how i can do that? thx.

this is my customMap activity:

public class CustomMapActivity extends MapActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

         String   provider = ""; 
         Criteria crit = new Criteria();
         Location loc = new Location("");
         LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

         MapView mapView = (MapView) findViewById(R.id.mapview);
         mapView.setBuiltInZoomControls(true);

         List<Overlay> mapOverlays = mapView.getOverlays();
         Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
         ItemizedOverlayedClass itemizedoverlay = new ItemizedOverlayedClass(drawable, this);

            try
            { 
             MyLocationOverlay mylocationOverlay = new MyLocationOverlay(this, mapView);
             mylocationOverlay.enableMyLocation();
             mapView.getOverlays().add(mylocationOverlay);          
             provider = mlocManager.getBestProvider(crit, false);
             loc = mlocManager.getLastKnownLocation(provider);
            }
            catch(Exception ex)
            {
            //Toast.makeText(this, "Unable to retrive provider", Toast.LENGTH_LONG).show();
            }


        for (ServiceActivity activity : DataSources.ActivitiesList)
        { 
            try
            {
                Location siteLocation =  new Location("");
                siteLocation.setLatitude(activity.SiteLatitude);
                siteLocation.setLongitude(activity.SiteLongitude);

                GeoPoint point = new GeoPoint((int)(activity.SiteLatitude * 1e6),(int)(activity.SiteLongitude * 1e6));
                OverlayItem overlayitem = new OverlayItem(point, activity.SiteName+ " " + activity.SiteAddress, "Distance to this location: " + String.valueOf(loc.distanceTo(siteLocation)/1000) + " km");

                itemizedoverlay.addOverlay(overlayitem);
                mapOverlays.add(itemizedoverlay);
            }
            catch(Exception ex)
            {
                @SuppressWarnings("unused")
                AlertDialogClass alert =  new AlertDialogClass(this,ex.getMessage());
            }
        }   




    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        //mylocationOverlay.enableMyLocation();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_map, menu);
        return true;
    }

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


}

and this is the overlay class:

package com.example.srwebservice;


import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class ItemizedOverlayedClass extends ItemizedOverlay {

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

    public ItemizedOverlayedClass(Drawable defaultMarker) 
    {
        super(boundCenterBottom(defaultMarker));
        // TODO Auto-generated constructor stub
    }

    public ItemizedOverlayedClass(Drawable defaultMarker, Context context) 
    {
      super(boundCenterBottom(defaultMarker));
      mContext = context;
    }

    @Override
    protected OverlayItem createItem(int i) 
    {
        // TODO Auto-generated method stub
         return mOverlays.get(i);
    }

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

    public void addOverlay(OverlayItem overlay)
    {
        mOverlays.add(overlay);
        populate();
    }
    @Override
    protected boolean onTap(int index) {
      OverlayItem item = mOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
      dialog.setTitle(item.getTitle());
      dialog.setMessage(item.getSnippet());
      dialog.show();
      return true;
    }
}
  • 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-15T02:42:04+00:00Added an answer on June 15, 2026 at 2:42 am

    i found a simpler solution.I can use google maps intent directly, and i don’t need to create a custom map activity anymore:

    if(DataSources.ActivitiesList.length >0)
    {
      String address = "http://maps.google.com/maps?daddr=" +    DataSources.ActivitiesList[0].SiteLatitude.toString() + "," + DataSources.ActivitiesList[0].SiteLongitude.toString();
    for (int i= 1 ;i <  DataSources.ActivitiesList.length ; i++) 
    {
        if(DataSources.ActivitiesList[i].SiteLatitude != null)
            address += "+to:" + DataSources.ActivitiesList[i].SiteLatitude + "," + DataSources.ActivitiesList[i].SiteLongitude;
    }
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(address));
        startActivity(intent);
        break;      
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
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
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
I want to show the soap response to UIWebview.. my soap response is, <p><img
This could be a duplicate question, but I have no idea what search terms

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.