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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:06:20+00:00 2026-06-15T00:06:20+00:00

I want show own loaction from a address was input by user use LocationOverlay

  • 0

I want show own loaction from a address was input by user use LocationOverlay and show position by a small dot or anything by icon….(ex: can show this position by a flag.png )But now i don’t know how show it on map.Can you help me!

source code:

public class Main extends MapActivity implements LocationListener {
private static double lat;
private static double lon;
private MapController mapControl;
private MapView mapView;
LocationManager locman;
Location loc;
String provider = LocationManager.GPS_PROVIDER;
String TAG = "GPStest";
Bundle locBundle;
private int numberSats = -1;
private float satAccuracy = 2000;
private float bearing;
private double altitude;
private float speed;
private String currentProvider;
private TextView txt;
private double lat1;
private double lon1;
private Drawable marker;
private Geocoder gcoder;
private MyLocationOverlay me = null;
long GPSupdateInterval; // In milliseconds
float GPSmoveInterval; // In meters
private MyMyLocationOverlay myLocationOverlay;
private List<Overlay> mapOverlays;
public DisplayOverlay displayOverlay;
private EditText address;
Button test;
private Button btnMylocation;
private Button btnAddrress;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_long_van_map);
    gps();
    btnMylocation = (Button) findViewById(R.id.button1);
    // get my location
    btnMylocation.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            gps();
        }
    });
    gcoder = new Geocoder(this);
    me = new MyLocationOverlay(this, mapView);
    address = (EditText) findViewById(R.id.editText1);
    btnAddrress = (Button) findViewById(R.id.button2);
    //Get postion from address
    btnAddrress.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String add = address.getText().toString();
            try {

                List<Address> addresses = gcoder
                        .getFromLocationName(add, 1);
                if (addresses == null) {
                    // return point;
                }

                // just get first item of list address
                Address add2 = addresses.get(0);

                lat1 = add2.getLatitude();
                lon1 = add2.getLongitude();

            } catch (IOException e) {

            }

            GeoPoint newPoint = new GeoPoint((int) (lat1 * 1e6),
                    (int) (lon1 * 1e6));
            mapControl.animateTo(newPoint);
            marker = getResources().getDrawable(R.drawable.startpoint);

            marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                    marker.getIntrinsicHeight());

            //mapView.getOverlays().add(new SitesOverlay(marker));
            mapView.getOverlays().add(me);

        }
    });

}

//Info gps of me
public void gps() {
    updateGPSprefs();
    locman = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Listener for GPS Status...
    final GpsStatus.Listener onGpsStatusChange = new GpsStatus.Listener() {
        public void onGpsStatusChanged(int event) {
            switch (event) {
            case GpsStatus.GPS_EVENT_STARTED:
                // Started...
                break;
            case GpsStatus.GPS_EVENT_FIRST_FIX:
                // First Fix...
                Toast.makeText(Main.this, "GPS has First fix",
                        Toast.LENGTH_LONG).show();
                break;
            case GpsStatus.GPS_EVENT_STOPPED:
                // Stopped...
                break;
            case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                // Satellite update
                break;
            }
            //GpsStatus status = locman.getGpsStatus(null);
            // Not presently doing anything with following status list for
            // individual satellites
            // Iterable<GpsSatellite> satlist = status.getSatellites();
        }
    };
    locman.addGpsStatusListener(onGpsStatusChange);
    locman.requestLocationUpdates(provider, GPSupdateInterval,
            GPSmoveInterval, this);
    Log.i(TAG, locman.toString());
    // Add map controller with zoom controls
    mapView = (MapView) findViewById(R.id.Mapview);
    mapView.setSatellite(false);
    mapView.setTraffic(false);
    mapView.setBuiltInZoomControls(true); // Set android:clickable=true in
                                            // main.xml
    int maxZoom = mapView.getMaxZoomLevel();
    int initZoom = (int) (0.95 * (double) maxZoom);
    mapControl = mapView.getController();
    mapControl.setZoom(initZoom);
    // Set up compass and dot for present location map overlay
    List<Overlay> overlays = mapView.getOverlays();
    myLocationOverlay = new MyMyLocationOverlay(this, mapView);
    overlays.add(myLocationOverlay);

    // Set up overlay for data display
    displayOverlay = new DisplayOverlay();
    mapOverlays = mapView.getOverlays();
    mapOverlays.add(displayOverlay);
    txt = (TextView) findViewById(R.id.textView1);
    txt.setText(LongVanMap.gettext());

}



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

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    // Called when location has changed
    centerOnLocation();

}

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    locman.removeUpdates(this);

}

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
    locman.requestLocationUpdates(provider, GPSupdateInterval,
            GPSmoveInterval, this);
}

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

    centerOnLocation();

}

// Method to assign GPS prefs
public void updateGPSprefs() {
    int gpsPref = Integer.parseInt(Prefs
            .getGPSPref(getApplicationContext()));
    switch (gpsPref) {
    case 1:
        GPSupdateInterval = 5000; // milliseconds
        GPSmoveInterval = 1; // meters
        break;
    case 2:
        GPSupdateInterval = 10000;
        GPSmoveInterval = 100;
        break;
    case 3:
        GPSupdateInterval = 125000;
        GPSmoveInterval = 1000;
        break;
    }
}

}

  • 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-15T00:06:20+00:00Added an answer on June 15, 2026 at 12:06 am
    @Override
    protected void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.maps_screen);
        initActionBar();
    
        String address = getIntent().getExtras().getString("address");
    
        String title = getIntent().getExtras().getString("title"); 
    
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
    
        Geocoder geoCoder = new Geocoder(this);
        List<Address> addresses;
    
        try {
            Log.i("maps", "getting geopoint for address: " + address);
    
            addresses = geoCoder.getFromLocationName(address, 1);
            if (addresses == null || addresses.isEmpty()) { 
                Log.i("maps", "couldn't get any matches for the following address: " + address);    
                isInvalidLocation = true;
                showInvalidAddressDialog();
                return;
            }
            Address location = addresses.get(0);
    
            GeoPoint point = coordinatesToGeoPoint(location.getLatitude(), location.getLongitude());
    
            Drawable marker = getResources().getDrawable(R.drawable.da_marker_red);
            MapOverlay adPos = new MapOverlay(marker,mapView);
    
            List<Overlay> overlays = mapView.getOverlays();
            OverlayItem overlayItem = new OverlayItem(point, title, address);
            adPos.addOverlay(overlayItem);
    
            overlays.add(adPos);    
    
            MapController mapcontroller = mapView.getController();
            mapcontroller.animateTo(point);
            mapcontroller.setCenter(point);
            mapcontroller.setZoom(12);
    
        } catch (Exception ex) {        
            Log.e("geocoder", "error using geocoder", ex);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show own phone number from android device with code like this
How can I show some default input while there is no user input? I
As the Question, I want to show my own menuStrip when I Right-click in
I'm spawning some processes running in their own gnome-terminal and don't want to show
i want to show leaderbord in my own game ....i am using following method
I want to use a MKMapView to display the user current location using the
I'm working on creating my own datetimepicker. I want to show the date as
We want to show a hint for a JList that the user can select
I want to create my own number pad to appear after user focus the
I have a textBox(EditText1) in android (Vs-2.3.3) I want to show my own mobile

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.