Open in another app generates geo: URI with a q= query compatible with Google Maps

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-06 01:38:28 +02:00
committed by Konstantin Pastbin
parent 30718e106e
commit 972cefb074
2 changed files with 3 additions and 1 deletions

View File

@@ -345,7 +345,7 @@ UNIT_TEST(GenerateShortShowMapUrl_UnicodeMixedWithOtherChars)
UNIT_TEST(GenerateGeoUri_SmokeTest)
{
string res = GenerateGeoUri(33.8904075, 35.5066454, 16.5, "Falafel M. Sahyoun");
TEST_EQUAL("geo:33.8904075,35.5066454?z=16.5(Falafel%20M.%20Sahyoun)", res, ());
TEST_EQUAL("geo:33.8904075,35.5066454?z=16.5&q=33.8904075,35.5066454(Falafel%20M.%20Sahyoun)", res, ());
// geo:33.8904075,35.5066454?z=16.5(Falafel%20M.%20Sahyoun)
// geo:33.890408,35.506645?z=16.5(Falafel%20M.%20Sahyoun)

View File

@@ -107,6 +107,8 @@ std::string GenerateGeoUri(double lat, double lon, double zoom, std::string cons
{
std::ostringstream oss;
oss << "geo:" << std::fixed << std::setprecision(7) << lat << ',' << lon << "?z=" << std::setprecision(1) << zoom;
// For Google Maps compatibility, otherwise it doesn't select the point on the map, only shows the area.
oss << "&q=" << std::setprecision(7) << lat << ',' << lon;
if (!name.empty())
oss << '(' << url::UrlEncode(name) << ')';