我使用了下面提供的答案并设法让它工作。我创建了一个新的 LatLong 而不是 GeoPoint 仅仅是因为 addMarkerHere 函数使用了该类型。这是我为将来可能需要它的任何人使用的代码:
Geocoder g = new Geocoder(this);
List<Address> addressList = null;
String searchRoad = "Insert Road Name Here!";
try {
addressList = g.getFromLocationName(searchRoad, 1);
} catch (IOException e) {
Toast.makeText(this, "Location not found", Toast.LENGTH_SHORT)
.show();
e.printStackTrace();
} finally {
Address address = addressList.get(0);
if (address.hasLatitude() && address.hasLongitude()) {
double selectedLat = address.getLatitude();
double selectedLng = address.getLongitude();
LatLng Road = new LatLng(selectedLat, selectedLng);
Marker Custom = map.addMarker(new MarkerOptions()
.position(searchedRoad).title("Here is the road location")
.snippet("Hon the lads"));
}