* Map Life Facts and Leaflet

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Map Life Facts and Leaflet

Post by tatewise »

I am tentatively picking up the Map Life Facts and changes to the Google Map Platform (15908) suggestion of using https://leafletjs.com/ to present maps and avoid the Google API Key in some scenarios.

I have briefly investigated the https://leafletjs.com/examples/quick-start/ guide, and your web pages Helen (ColeValleyGirl) such as http://www.colevalleygirl.co.uk/tree/g1/p3.htm that you kindly offered.

I have got some very basic markers and popups working with Leaflet on a Mapbox Streets tile layer.
However, there are a few initial stumbling blocks that I hope you can help me with before digging into the API.
  1. In the Leaflet Quick Start Guide the CSS and JavaScript header lines need a long integrity code.
    But it seems to work without, and Helen your web page appears to have no integrity code either.
  2. The Leaflet Quick Start Guide uses Mapbox Streets that needs an accessToken.
    On visiting https://www.mapbox.com/account/access-tokens/ and creating an account they offer a Default public token.
    So can that be built into the Plugin and used indefinitely by everyone?
    OR does each user need their own account & accessToken, similar to a Google API Key but easier to obtain.
  3. The Leaflet FAQ says Bing Maps may be used, and it looks like you use them too Helen instead of Mapbox Streets.
    Does that avoid the need for any access tokens or keys?
    If so, can you give some clues to script to include Bing Maps tiles instead of Mapbox Streets.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
ColeValleyGirl
Megastar
Posts: 5502
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Map Life Facts and Leaflet

Post by ColeValleyGirl »

Mike

1. The integrity code (if I remember correctly) is an additional security measure to deal with potential script injection attacks -- unlikely to happen in this use case.

2. I can't help re Mapbox Streets as I don't use them, but instinctively, I'd prefer a separate key per user.

3. The Bing integration for my site is handled using a Drupal module (and there's no key involved anywhere, although https://www.bingmapsportal.com/ suggests some uses might need one.) I've no experience with integrating 'naked' leaflet but https://stackoverflow.com/questions/tag ... +bing-maps might be useful.
User avatar
BillH
Megastar
Posts: 2257
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Map Life Facts and Leaflet

Post by BillH »

tatewise wrote:I am tentatively picking up the Map Life Facts and changes to the Google Map Platform (15908) suggestion of using https://leafletjs.com/ to present maps and avoid the Google API Key in some scenarios.
Mike,

I am not sure what scenarios you are thinking of using Leaflet for, but I know I would be disappointed if you changed from Google Maps to Leaflet as the default. In my looking around at Leaflet maps, they seem to be much less detailed especially in Norway. Some farm names which are available in Google Maps do not appear to be available in Leaflet.
Bill Henshaw
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

Bill, I'm not considering removing any options, and Plugin Geocoding will continue to be able to use Google Maps.
Some users may be uncomfortable with having their Google API Key in scripts on public websites where it may be stolen.
So having the option to use Leaflet to display Maps without a Google API Key may be attractive.
This would be primarily applied where the Plugin is used to Create Web Page Maps via the tab of that name.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
BillH
Megastar
Posts: 2257
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Map Life Facts and Leaflet

Post by BillH »

Mike,

I see, thanks for the explanation.
Bill Henshaw
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

A prototype Map Life Facts Plugin Version 4.2.4 Date 22 Sep 2018 ZIP file is attached. So unpack before use.
[EDIT: Attachment deleted as Plugin V4.5 is in Plugin Store.]

It incorporates the fixes from the Map Life Facts Plugin Error (16239) thread.

It supports both a Google Maps and Leaflet Mapbox style of map presentation.
They are chosen via the Set Preference Options > Web Page Map Options tab Map Pane Mode setting.
I am hoping that the Leaflet Mapbox public access key that the Plugin uses will work for everyone.

Apart from marker icons being blue their style in Leaflet Mapbox mode is similar to Google Maps, except that they Flash instead of Bounce (although I have designed a Bounce mode for them too). The big benefit is the Google Maps API Key is NOT embedded in the online Web Page mapfacts.js file, so cannot be compromised.

When the Create Web Page Maps tab Map **** Individual buttons are used, the map**.html files will use a slightly new format that eliminates all Google/Leaflet dependencies, which will allow other Map Pane Modes to be more easily added.

BUT that means any existing map**.html files in the same folder would not work with the new mapfacts.css and mapfacts.js files.
So the Plugin detects such files, and the user prompted to update them to the new format.
If you don't want such files altered, answer No.
Alternatively, to keep such existing files, use a new output folder on the Set Preference Options > Web Page Map Options tab.

I have briefly tried the Web Page Map files with the current Firefox, Chrome, IE, and Edge browsers.

It should be possible to revert to the Plugin Store or Map Life Facts Plugin Error (16239) versions of the Plugin without any harm, providing you take care with new/old format files.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

It seems that 5 users have downloaded the prototype Plugin. Have any of you any feedback?
I have been running further tests, and added some extra bells & whistles.

Thus prototype Map Life Facts Plugin Version 4.2.5 Date 25 Sep 2018 ZIP file is attached. Unpack before use.
[EDIT: Attachment deleted as Plugin V4.5 is in Plugin Store.]

The testing revealed that some Leaflet functions are time sensitive and needed time delays to avoid errors.
If you have been getting script errors, then this is probably why.

The maps pane now has a scale in lower left corner, and an icon top right to choose different map displays.
The options are OpenStreetMap or Mapbox Streets or Mapbox Satellite. Currently that choice is not sticky.
I investigated and rejected Bing Maps as that needs a personal access key rather like Google Maps.
Does anyone have any other possible maps?

The Leaflet markers now Bounce, because with two or more coincident markers the Flash was not visible.

All markers are now draggable, so if some are coincident, they can be dragged apart, and more easily clicked.
However, that does not alter their geocoded Lat/Longitude, and they will return when next displayed.
But in the Plugin Geocode Location Plots tab it may offer the possibility of plotting by dragging similar to FH Maps Window.
Together with manually entering Lat/Longitude and the N S E W nudging, the Plugin may be functional enough without needing automatic geocoding from Google Maps, which then becomes an option and only then needs an API Key.
What do you think?

I am not sure why, but the markers are placed much more rationally on Google Maps than on Leaflet Maps.
On Google Maps the tip of the marker almost always sits just above the place name.
On Leaflet Maps the marker is often above, below, left, or right of the place name.
Maybe the positioning of place names is not consistent with their Lat/Longitude in those maps?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

Just as an aside on this, you can use the NLS 1920's map tiles with Leaflet, useful when plotting streets on Cities bombed in the 2nd World War.

See https://maps.nls.uk/projects/api/
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

I have been able to add those NLS Historic Maps to the Plugin.
The user just needs to be wary that they only cover England, Scotland & Wales.
If locations elsewhere are plotted, then the screen goes grey, but easily switched back to one of the other maps.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

Sorry Mike, silly question. All my locations are geocoded in FH, so I don't need to geocode them in the plugin but for some reason it's not letting me create maps. Have I missed another setting?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

I assume you are using V4.2.5 attached earlier.
Presumably you are getting the message saying API Key Required.
I did ask "What do you think?" on 25th when I posted that version to get feedback about using Plugin without an API Key.

The trick for the moment is to enter any alphanumeric 39 character Google Maps API Key.
Then you can use Leaflet Maps but NOT Google Maps that need a valid API Key.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

Not having much luck, when I put a 39 char key in and try to use the Create Maps, it's still trying to use Google and obviously failing as the key is not valid, I can't see any un-geocoded locations on my records.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

Presumably it is saying Geocoder API Request Denied see Help & Advice F.A.Q.?
What does Map Life Facts say for Statistics on Geocode Location Plots tab?
They should all be either Plotted or Defined with the other three 0.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

I have 568 showing no data, I don't want the plugin to code them. All my locations have valid geocodes in the Place fields, so I don't know why it's showing them as wrong and I don't want to run the routine as I spent ages getting all the plots exactly where I wanted them, how do I get the plugin just to use the place locations to generate the maps?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

If 568 locations have No Data then they have NOT been Geocoded.
If any Map needs one of those locations, then it will try to Geocode it, otherwise how can it plot its marker on the Map?
Any specific Map that only uses Plotted or Defined locations should work OK.

Is the Plugin location data synchronised with your Project Place records?
i.e. On the Set Preference Options tab, Location Plot Options tab, is Database In: set to Place Records?
I suspect the database may be in Plugin Data Folder.

BTW: If in FH you have set all your carefully plotted Places to non-Tentative then in the Plugin they should appear as Defined and those will NOT be Geocoded unless you specifically request that.
The Maps will only Geocode locations without a Lat/Longitude plot.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

I have a prototype Map Life Facts Plugin that allows the Google Maps API to be Disabled.
It also allows Maps to be created even if some Places/Locations have not been Geocoded.
The Facts are included, but there is no hyperlink to a map Marker because it does not exist.
In the Plugin, Markers can be dragged, and Lat/Long entered, to manually plot Places/Locations similar to FH.

Jane, your Plugin Locations must still be synchronised with FH Place records to use FH Geocoded plots.

Is anybody interested?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

I'll give it a go, but won't have time till I get back.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

Attached is prototype Map Life Facts Plugin Version 4.2.6 Date 18 Oct 2018 ZIP file (unpack before use) with the following new features, but the Help & Advice is not updated as that still relates to the Plugin Store version.
[EDIT: Attachment deleted as Plugin V4.5 is in Plugin Store.]

Initially, if the Google API Key is missing, the API Key Required popup dialogue appears as before and offers:-
  • Enter the 'API Key' button exactly as in previous versions.
  • Disable Google API button is an alternative option, new in this version.
    On the Set Preference Options > Location Plot Options tab it unticks the new Enable Google API option.
    On the Set Preference Options > Web Page Map Options tab it sets Map Pane Mode to Leaflet Maps.
When Enable Google API is NOT ticked:-
  • On the Geocode Location Plots tab the three Geocode Plot ... Locations buttons are disabled.
  • On the Create Web Page Maps tab the three Map ... Individuals buttons allow the Location in any Fact to be without Lat/Longitude values and does NOT try to Geocode them. Each such Fact is still listed in exported web pages, but has no hyperlink as there is no Marker.
  • If Map Pane Mode is set to Google Maps then Oops! Something went wrong is shown in map pane.
Map Pane Mode new features:-
  • Leaflet Maps mode now includes a Scale bar lower left, and a map Style drop-list top right, which is sticky, and determines what Style appears by default in exported web page maps.
  • In any Map Pane any Marker can be dragged to allow congested Markers to be viewed, but they return to their original positions when the map is redisplayed, except in the case below.
  • In the Geocode Location Plots tab the Marker can be dragged to alter its Lat/Longitude values to supplement N, S, E, W nudge buttons or entering Lat/Longitude values manually.
  • Also on that tab a new Marker is created by right-click in Google Maps mode, or double-left-click in Leaflet Maps mode.
Let me know if anything does not work as it should.

It may be possible to add an alternative geocoder to Google Maps but I'm not sure they offer any better plotting than available in FH.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

> On the Create Web Page Maps tab the three Map ... Individuals buttons allow the Location in any Fact to be without Lat/Longitude values and does NOT try to Geocode them. Each such Fact is still listed in exported web pages, but has no hyperlink as there is no Marker.

Would it be possible to use the Geocode data in the Place records as a fall back, if none exists in the custom coding?

When you click on a link on the generated page, the map scrolls all the way out rather than zooming in, is this intentional?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

I'm not entirely clear what you are asking for in using "the Geocode data in the Place records".
If the Location Plot Options tab, sets Locations From: to Place Fields only and Database In: to Place Records, then the FH Geocode data will be used as explained in the Help & Advice plugins:help:map_life_facts:the_faq#how_can_v6_place_records_be_synchronised_with_plugin_locations|> Map Life Facts ~ Frequently Asked Questions > How can V6 Place Records be synchronised with Plugin Locations?
If not using that setting, and Google Maps API is disabled, every Location will have no Geocode data.

In a generated web page, when you click on a Place hyperlink, it should pan and zoom the map pane to focus on the associated Marker, but the zoom level is determined by the Web Page Map Options setting for Map Zoom. So, I suspect that has a low single digit value, and the + Zoom In button on the Plugin map pane should be clicked until Map Zoom is about 12, which is sticky and should be remembered. That sets the zoom level when a Place hyperlink is clicked.

If that is not the cause, then what browser are you using, and what Map Pane Mode is chosen?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Post by Jane »

Thanks Mike, I had not changed the Database as it gave dire warnings about changing my Places in the GEDCOM. I could not find the setting it wanted me to change. All working now.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28413
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Post by tatewise »

Map Life Facts Plugin Version 4.4 Date 10 Nov 2018 is now in the Plugin Store.

I've nearly finished updating the plugins:help:map_life_facts:map_life_facts|> Map Life Facts Plugin Help & Advice pages.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Post Reply