This commit is contained in:
Naumov Dmitry 2021-01-17 16:54:17 +05:00
parent f1bdb378ea
commit bf5de1a4e2
2 changed files with 9 additions and 5 deletions

View file

@ -333,8 +333,8 @@ public class MapUtils {
}); });
} }
public static String buildGeoUrl(double latitude, double longitude, int zoom) { public static String buildGeoUrl(String latitude, String longitude, int zoom) {
return "geo:" + ((float) latitude) + "," + ((float) longitude) + "?z=" + zoom; return "geo:" + latitude + "," + longitude + "?z=" + zoom;
} }
// Examples // Examples

View file

@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import androidx.core.text.TextUtilsCompat; import androidx.core.text.TextUtilsCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import net.osmand.LocationConvert;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -99,10 +100,13 @@ public class ShareMenu extends BaseMenuController {
if (mapActivity == null) { if (mapActivity == null) {
return; return;
} }
String lat = LocationConvert.convertLatitude(latLon.getLatitude(), LocationConvert.FORMAT_DEGREES, false);
String lon = LocationConvert.convertLongitude(latLon.getLongitude(), LocationConvert.FORMAT_DEGREES, false);
lat = lat.substring(0, lat.length() - 1);
lon = lon.substring(0, lon.length() - 1);
final int zoom = mapActivity.getMapView().getZoom(); final int zoom = mapActivity.getMapView().getZoom();
final String geoUrl = MapUtils.buildGeoUrl(latLon.getLatitude(), latLon.getLongitude(), zoom); final String geoUrl = MapUtils.buildGeoUrl(lat, lon, zoom);
final String httpUrl = "https://osmand.net/go?lat=" + ((float) latLon.getLatitude()) final String httpUrl = "https://osmand.net/go?lat=" + lat + "&lon=" + lon + "&z=" + zoom;
+ "&lon=" + ((float) latLon.getLongitude()) + "&z=" + zoom;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (!Algorithms.isEmpty(title)) { if (!Algorithms.isEmpty(title)) {
sb.append(title).append("\n"); sb.append(title).append("\n");