Can you get latitude hardness from the address?

Asked 2 years ago, Updated 2 years ago, 51 views

I'd like to mark the location on Google Maps with an address. Can I get latitude hardness from the address using Google Maps API?

android google-geocoder google-maps

2022-09-22 08:04

1 Answers

public GeoPoint getLocationFromAddress(String strAddress){

Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;

try {
    address = coder.getFromLocationName(strAddress,5);
    if (address==null) {
       return null;
    }
    Address location=address.get(0);
    location.getLatitude();
    location.getLongitude();

    p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
                      (int) (location.getLongitude() * 1E6));

    return p1;
    }
}

strAddress is a string containing an address The address variable stores the translated address.


2022-09-22 08:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.