# "Look up with Map Service" uses a bad URL

**URL:** <https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382>\
**Category:** Help\
**Tags:** hacks\
**Created:** [November 7, 2023, 4:21pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382 "2023-11-07T16:21:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 7, 2023, 4:21pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/1 "2023-11-07T16:21:47Z")

</div>

While looking for instances of adding menu items to the context menu, I noticed the **Look up with Map Service** context menu for Place views. My [Map Service](https://www.gramps-project.org/wiki/index.php/Gramps_5.2_Wiki_Manual_-_Categories#Map_Service) was defaulted to OpenStreetMaps

When trying this for a “Boston, Suffolk, Massachusetts, United States” hierarchical place, it linked to a malformed URL:  
`https://nominatim.openstreetmap.org/ui/search.php.html?q=Boston,+Suffolk,+Massachusetts,+United+States`

Changing the `search` ~~`.php`~~ `.html` to `search.html` makes the URL work. ~~(Eliminating both extensions also works.)~~

Where can this code be found to hack?:

> <https://github.com/gramps-project/gramps/blob/7c1861d0340d1ee850eb6ae68e0d7772e85a4e1d/gramps/plugins/mapservices/openstreetmap.py#L62>

   
   
The docs in the wiki for this feature are rudimentary. Since services frequently change their URL and parameter passing format, features like this (and the Web Connections) probably need a hackers guide. Or maybe be changed to use an external CSV file or GUI editable config table.

---

<div class="post-metadata">

**Author:** ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)\
**Post date:** [November 7, 2023, 6:10pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/2 "2023-11-07T18:10:05Z")

</div>

Try this commit:

> <https://github.com/gramps-project/gramps/commit/7c1861d0340d1ee850eb6ae68e0d7772e85a4e1d>

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 7, 2023, 11:20pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/3 "2023-11-07T23:20:03Z")

</div>

> [@emyoulation](#):
>
> `.php`

The `.php` is removed in 5.2.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 7, 2023, 11:30pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/4 "2023-11-07T23:30:33Z")

</div>

That the offending `.php` is removed in 5.2 is great.

But such map services are likely to suffer linkrot since the services have to change frequently. They have to reduce the number of people (or robots) using such testbeds for batch production work.

Gramps has enough interface in the way that we don’t put a big load on them. But the linkrot is probable anyway… as a consequence of their combating the abusers.

We could use an example of converting a feature to store these perishable items in a CSV in a folder of the User Directory. And a tool for editing that table inside Gramps.

With one example, then the others ([Web Connections](https://www.gramps-project.org/wiki/index.php/Addon:Web_Connect_Pack), [Sync Associations](https://gramps-project.org/wiki/index.php/Addon:SyncAssociation) and similar tools) can be adapted in the same way.

---

<div class="post-metadata">

**Author:** ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)\
**Post date:** [November 8, 2023, 12:33am UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/5 "2023-11-08T00:33:30Z")

</div>

That would be nice indeed, because the web connections are a mess anyway, especially when you install different versions. They are nice to get French, English, and German sites, but I really don’t care about having French, English, and German Googles.

---

<div class="post-metadata">

**Author:** ![Davesellers](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesellers/32/1457_2.png) [@Davesellers](https://gramps.discourse.group/u/Davesellers)\
**Post date:** [November 8, 2023, 4:09pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/6 "2023-11-08T16:09:21Z")

</div>

It surprised me that external links are not all in a central configuration file. With due respect to the developers here, I understood that it was not a good programming technique to hardcode anything that could change.  
I strongly agree that there should be one place to store all external links.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 8, 2023, 5:16pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/7 "2023-11-08T17:16:16Z")

</div>

> [@Davesellers](#):
>
> I understood that it was not a good programming technique to hardcode anything that could change.

These sorts of things are an evolution. Features tend to be hard-coded until a reason arises making them adjustable. That always requires adding error-handling. Then another enough reason arises to invest the effort to build an interface.

In this case, there might be enough reusability potential to make a reusable module for Gramps.

The multiple OS support makes validating a filepath (which might include a local hard drive, removable storage or a network location; or a URI/URL) quite a challenge.

An enhancement that that been discussed for 5.3 of the new Addon Manager’s “Projects” would be some validation feedback for a ‘good’ path. This feature already has the ability to extend the list, to enable/disable paths without deleting them, and the ability to edit named targets.

It seems like making this URL ‘selector’ reusable would be the next logical step.

And maybe adding a built-in option to toggle between URL and local path selector would be good too. Having to figure out that the local filepath needs to be prepended with a `file:///` (with 3 slashes) instead of `http://` or `https://` is a bit confusing. Plus, the Local Media Path and Backup Path can be browsed to set the path. That’s a lot more foolproof than typing (or pasting-then-editing) a path.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 8, 2023, 5:41pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/8 "2023-11-08T17:41:55Z")

</div>

> [@Davesellers](#):
>
> It surprised me that external links are not all in a central configuration file. With due respect to the developers here, I understood that it was not a good programming technique to hardcode anything that could change.

New map services can be created using the addon process. I suppose that existing services could all be made addons so that they could be easily updated when the service changes its URL parameters. OpenStreetMaps dropping the `.php` parameter is the first change that I am aware of over many years and Gramps versions.

But that raises the issue of some users never adding available addons. The functionality would be lost to them. Does Gramps make certain addons mandatory?

As another open-source project, OpenStreetMaps would probably be the goto option.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 8, 2023, 5:50pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/9 "2023-11-08T17:50:05Z")

</div>

> [@emyoulation](#):
>
> When trying this for a “Boston, Suffolk, Massachusetts, United States” hierarchical place, it linked to a malformed URL:

I had been having no luck getting openstreetmap to recognize and lookup Boston, Suffolk Co, Massachusetts when no Lat/Lon coordinates where part of its Gramps record.

I just found the problem. OSM did not like the “`, U.S.A.`” that I use as the country entry. It does like “`, USA`”.

---

<div class="post-metadata">

**Author:** ![Davesellers](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesellers/32/1457_2.png) [@Davesellers](https://gramps.discourse.group/u/Davesellers)\
**Post date:** [November 8, 2023, 9:29pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/10 "2023-11-08T21:29:48Z")

</div>

I had to fix the URL for Open Street mapping for the Narrated Web to work in 5.1.5 and 5.1.6. Does anyone know if this got fixed in 5.2. I think it was in the “report” file.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 8, 2023, 9:33pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/11 "2023-11-08T21:33:30Z")

</div>

> [@Davesellers](#):
>
> Does anyone know if this got fixed in 5.2

It’s fixed in Gramps5.2 beta!

---

<div class="post-metadata">

**Author:** ![Davesellers](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesellers/32/1457_2.png) [@Davesellers](https://gramps.discourse.group/u/Davesellers)\
**Post date:** [November 8, 2023, 9:56pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/12 "2023-11-08T21:56:23Z")

</div>

Thanks for the info. That’s good.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 8, 2023, 10:26pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/13 "2023-11-08T22:26:47Z")

</div>

> [@DaveSch](#):
>
> It’s fixed in Gramps5.2 beta!

Have you tried that map service today with the 5.2 beta and a Place with no GPS coordinates?

My 5.1 linux box didn’t like the URL without the `.html` extension after the `search`.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 8, 2023, 11:05pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/14 "2023-11-08T23:05:39Z")

</div>

> [@emyoulation](#):
>
> Have you tried that map service today with the 5.2 beta and a Place with no GPS coordinates?
> 
> My 5.1 linux box didn’t like the URL without the `.html` extension after the `search`.

I think you are confusing two different mapping activities.

My… “It’s fixed in Gramps5.2 beta!” was referring to the blank maps that were appearing in the Narrative Web because of the “latest” versus specific vision release in the openlayers tools. It did not get fixed in 5.1.6 even though it was identified in 5.1.5.

As to the mapping service from the place view list, that is working in 5.2 for the OpenStreetMap service when there is no GPS in the Gramps’ place record. As I pointed out, it does not like my use of “U.S.A.” as a country entry.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 9, 2023, 1:32am UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/15 "2023-11-09T01:32:22Z")

</div>

I wasn’t confused. I looked at the patch Enno mentioned for 5.2

> <https://github.com/gramps-project/gramps/blob/037c5d3fb3e8a63d2a3ad34091322e0c00ee2628/gramps/plugins/mapservices/openstreetmap.py#L65>

That _looks_ like it would generate a URL with `search?q=` but a test with the 5.2 beta still generates ` search.html?q=` instead.

I’m trying to understand how this line inserts the needed `.html` portion of the URL.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [November 9, 2023, 3:04am UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/16 "2023-11-09T03:04:49Z")

</div>

I am not sure why or how, but sending that code to your browser, the `.html` gets added.

`https://nominatim.openstreetmap.org/ui/search.html?q=Basin,+Big+Horn+Co,+Wyoming,+USA`

---

<div class="post-metadata">

**Author:** ![SNoiraud](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/snoiraud/32/72_2.png) [@SNoiraud](https://gramps.discourse.group/u/SNoiraud)\
**Post date:** [November 9, 2023, 10:15am UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/17 "2023-11-09T10:15:40Z")

</div>

OpenStreetMap makes a redirection. If you look at correctly, you can see “ui/” has been added just before “search”

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 9, 2023, 11:34am UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/18 "2023-11-09T11:34:24Z")

</div>

That’s interesting!

The service that hosts my family website logs redirections. The reports of where those originate help me identify patterns of abuse. And I can use that to design changes.

And on the user side, some anti-malware tools monitor for redirection results. And some browser plugins or settings can let the user suppress suspicious redirections.

On the other hand, some rewriting is expected for masking access vulnerabilities.

Are we able to monitor some sort of Failed Request Monitoring to see status codes?

Redirection results might be an early warning sign of linkrot.

---

<div class="post-metadata">

**Author:** ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)\
**Post date:** [November 9, 2023, 3:36pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/19 "2023-11-09T15:36:03Z")

</div>

> [@emyoulation](#):
>
> I’m trying to understand how this line inserts the needed `.html` portion of the URL.

It looks like it’s added automatically somewhere down the line. In my original fix, I replaced .php with .html, and that resulted in a double .html in Firefox, so I removed it right away.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 9, 2023, 4:24pm UTC](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382/20 "2023-11-09T16:24:54Z")

</div>

The doubling of the `.html` is even more interesting. That indicates Gramps is doing something behind the scenes.

It’s always good to pull back the curtains on such things.

[Next page](https://gramps.discourse.group/t/look-up-with-map-service-uses-a-bad-url/4382.md?page=2)
