*Map Life Facts and Leaflet

Writing and using plugins for Version 5 and above.
User avatar
tatewise
Megastar
Posts: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Map Life Facts and Leaflet

Postby tatewise » 17 Sep 2018 14:08

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.

User avatar
ColeValleyGirl
Megastar
Posts: 715
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Map Life Facts and Leaflet

Postby ColeValleyGirl » 17 Sep 2018 14:25

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: 1303
Joined: 31 May 2010 03:40
Family Historian: V6.2
Location: Washington State, USA

Re: Map Life Facts and Leaflet

Postby BillH » 17 Sep 2018 16:11

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: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 17 Sep 2018 16:42

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.

User avatar
BillH
Megastar
Posts: 1303
Joined: 31 May 2010 03:40
Family Historian: V6.2
Location: Washington State, USA

Re: Map Life Facts and Leaflet

Postby BillH » 17 Sep 2018 16:46

Mike,

I see, thanks for the explanation.
Bill Henshaw

User avatar
tatewise
Megastar
Posts: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 22 Sep 2018 17:13

A prototype Map Life Facts Plugin Version 4.2.4 Date 22 Sep 2018 ZIP file is attached. So unpack before use.

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.
Attachments
Map Life Facts.zip
Version 4.2.4 Date 22 Sep 2018 ZIP file
(94.65 KiB) Downloaded 8 times
Mike Tate ~ researching the Tate and Scott family history.

User avatar
tatewise
Megastar
Posts: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 25 Sep 2018 20:39

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. Upack before use.

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?
Attachments
Map Life Facts.zip
Version 4.2.5 Date 25 Sep 2018 ZIP file
(95.07 KiB) Downloaded 4 times
Mike Tate ~ researching the Tate and Scott family history.

User avatar
Jane
Site Admin
Posts: 7287
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Postby Jane » 29 Sep 2018 10:49

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: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 29 Sep 2018 15:27

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.

User avatar
Jane
Site Admin
Posts: 7287
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Postby Jane » 30 Sep 2018 08:52

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: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 30 Sep 2018 14:01

I assume you are using V4.2.5 attached earlier.
Presumably you are getting the message saying API Key Required.
It 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.

User avatar
Jane
Site Admin
Posts: 7287
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Postby Jane » 01 Oct 2018 10:32

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: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 01 Oct 2018 11:52

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.

User avatar
Jane
Site Admin
Posts: 7287
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Postby Jane » 01 Oct 2018 12:51

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: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 01 Oct 2018 13:41

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.

User avatar
tatewise
Megastar
Posts: 14439
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts and Leaflet

Postby tatewise » 02 Oct 2018 20:09

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.

User avatar
Jane
Site Admin
Posts: 7287
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Map Life Facts and Leaflet

Postby Jane » 03 Oct 2018 07:22

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."


Return to “Plugin Discussions”

Who is online

Users browsing this forum: No registered users and 7 guests