Jump to content
TNG Community
XerxX

Replacing Google Maps with OSM

Recommended Posts

XerxX

This thread is a continuation of the thread "Google Map API Change"

and is only about using Open Street Maps instead of Google Maps if you don't have a Google Map API key.

(Or if you have exceeded your limit and Google doesn't show the maps ;) )

Ultimately this will become a mod to be used in these cases.

 

So the current stage of the development is this (and is working at my site - starting links below):

* I have installed the latest Open Layer JavaScript and .css files at the server (speeding things up a bit)

* I have made a new "osmmaplib.php" to be used instead of "googlemaplibOSM.php" that I used before

* getpersonOSM.php works.

- - - The map boundaries may not be the best as I haven't fine-tuned the different levels yet

- - - Person-links open a "OSM-getperson" page (you don't have to insert anything in the URL)

- - - Magnifying glasses in "Person-places" (not to the right of the map) open a "OSM-placesearch" page

* placesearchOSM.php works

- - - Person-links open a "OSM-getperson" page

- - - Swedsih places have zoom = 10, European = 7 (mostly) and USA = 5 (mostly)

 

To do:

* Modify the cemeteries page like the placesearch.php

* Make the Admin pages show OSM and accept point-and-click coordinates

- - - There is an example of retreiving coordinates (Lat & Long) in the docs 😄

* Fine-tune the zoom levels for getperson maps

 

The modifications are collected in a mod that I install in my TNG v12 test environment (w/o API key), thereby making sure it will work.

(I want to keep the OSM pages separate from my live site...)

The mod will probably work also w/ an API key as I simply (so far anyway) could just remove the "$map['key'] conditions".

 

A link for a person: https://xerxx.se/getpersonOSM.php?personID=I158&tree=tredNr2

A link for a place: https://xerxx.se/placesearchOSM.php?psearch=Almby%2C+Örebro+län&tree=tredNr2

You can select English or German by the flags up left.

Questions? Ask them here...

 

Regards,

Erik

Share this post


Link to post
Share on other sites
Newfloridian

Will this mod ultimately be compatible with previous versions of TNG? I've had Googlemaps running without API or map key but with  $siteKey; and &secret; variables (presumably from Google) placed in  customconfig.php since the earliest days (?TNG 5) - now at TNG10.1.3

Alan

 

 

 

Share this post


Link to post
Share on other sites
XerxX

Hi Alan,

I do _hope_ so and today I can't see why not. But it's primarily made for TNG v11 and v12.

v11 because that's my live site today (using a key = "1" ;) ) and v12 for the future.

/Erik

Share this post


Link to post
Share on other sites
Chris Lloyd

Looks like a good fix Eric - thanks.

Share this post


Link to post
Share on other sites
XerxX

Thanks Chris! Encouragement is always welcome :)

 

Now both headstonesOSM.php and showmapOSM.php works.

You can start here:

https://xerxx.se/getpersonOSM.php?personID=I2&tree=tredNr2

Click the magnifying glass for her burialplace and there you can select the cemetery.

 

 

There is also a heat map in TNG - I forgot about that.

I saw some kind of heatmap among the examples in the OSM docs. I will try to make something out of it.

/Erik

Share this post


Link to post
Share on other sites
Ken Roy

Looking good Erik,

Will the Person Map (or Mobile Individual Page Map - Person Map) mods also work?

What about the Google Maps - More Place Levels and Google Maps 15 mods?

and the Geocode Assist Mod?

I imagine those mods will require an OSM version.

 
 
 

Share this post


Link to post
Share on other sites
XerxX

Thanks Ken,

Actually; I run Mobile Ind Page Map and Gmaps add 4 placelevels w/o any modifications. Look at the legend.

EDIT: I _have_ modified the mods a bit but that was previous and not for this purpose.

In the getpersonOSM.php script the only changes are that the $map['key'] part of conditions are removed.

The map is then put there by the osmmaplib.php (equivalent to googlemaplib.php) so there is no need for new versions.:)

 

And I just now had confirmation from my bank that they don't have pre-paid cards w/o connection to my account.

I have to apply for a separate account which, including a card, will cost me like $3.50/month!

Stupidity!

/Erik

Share this post


Link to post
Share on other sites
Ken Roy

Thanks Erik,

i will have to double check.  i thought some of those mods did make some modifications to googlemaplib.php. 

Others like me will certainly appreciate the work you are doing on developing an alternative, since i certainly will not provide a credit card, not even a prepaid card.

If there is anything I can do to help, let me know.  I would be interested in what kind of modifications you made to the mods, so contact me off list and off forum.

Share this post


Link to post
Share on other sites
XerxX

Hi All,

I had this question in a mail and I thought I should reply also here as more may wonder the same thing:

NO! There will NOT be two separate pages (f.ex. both a getperson.php and a getpersonOSM.php) - that is _only_ at my live site while testing.

I want to keep my ordinary pages (w/ Google maps) intact while testing, and displaying the OSMs for you.

Visitors that don't know about it don't see the OSMs.

/Erik

(Ken: You have mail)

Share this post


Link to post
Share on other sites
pleijtng

Top Erik,

I look forward to the Mod, I use version 12.
As long as we are rid of Google's conditions.

Hans

Share this post


Link to post
Share on other sites
XerxX

Hi all,

I use the mod Mobile Ind Page Person Map and I have discovered something that happens when it is installed:

If you collapse and then expand the map it is doubled! This is not good.

https://xerxx.se/getpersonOSM.php?personID=I2&tree=tredNr2

It doesn't happen w/o the mod (it seems...) nor with the mod and Googlemaps.

Anyone got any idea why? Please...

 

I'm right now trying to make the admin_editplace.php work because I think that w/o the point-&-click interface this mod will be almost useless.

(Either we will have to enter the coordinates by hand (copy-&-paste from somewhere - where?) or the mod can only display maps already in the database.)

/Erik

 

Share this post


Link to post
Share on other sites
Ken Roy

Erik,

Sorry, I did not get a chance to check into that yesterday.

Can you uninstall the Mobile Site Enhancements mod and install Bart's original Person Map mod and let me know if it has the same behavior, so I can know whether this is a problem I introduced when creating a mobile version. 

Share this post


Link to post
Share on other sites
XerxX

(Ken already knows this ;) )

For the rest of you:

Yes; the same thing happens with Person Map mod installed.

It's obviously something with the OSM code... Or something else 😄

/Erik

Share this post


Link to post
Share on other sites
XerxX

All,

This is a small status report: I'm making progress with the admin_editplace.php:

The marker is originally placed at Vimmerby (right end of map) and I click at Eksjö (left end):

vimmerby.jpg

 

The map will center itself at Eksjö (not shown bec of space), the marker is placed there and the coordinates are in the boxes:

eksjo.jpg

 

Next step is to update the database.

But it's very hot and a clear blue sky outside. Almost 5 PM... I have  to stop now ;)

(It will officially be the hottest May ever in Sweden - they already know that)

Erik

Share this post


Link to post
Share on other sites
XerxX

Now able to Update and Add New:

addosm.jpg

This place was originally somewhere else and named something different and of a different kind (address - now town) and in a lower zoom.

:)

 

Share this post


Link to post
Share on other sites
Katryne

Hello Erik !

Just to let you know I am following your progress with utmost attention.

Tell me if you have any text to translate, I will do it to French.

Share this post


Link to post
Share on other sites
XerxX

Thanks Katryne!

For you and anyone interested: The Edit and Add place seems to work fine.

The admin_newplace.php

1.jpg

Click the button to open an "empty" map:

2.jpg

Click the magnifying glass and you will have a box to type a place-name or address or...

Press Enter and there is a list of up to five suggestions (can be set) - click one

3.jpg

And the map will zoom in and point to the place, showing the name, coordinates and zoom level in their boxes:

4.jpg

The control zooms in very much (16!) and I don't know where to modify it. But that's not a matter of priority right now. For me... There is that -button ;)

BTW: I have a variable where I put "Sweden" to strip my/a default country from the name. Compare the name in the namebox and the name in the "pointing box".

I will try to make it an MM option.

I also add the commas to the name - it is divided into HTML <span class=...></span> tags that of course can't be stored in the database.

 

Anyway: I zoom out, set a type (address) and click Save. The result:

5.jpg

I hope I have made it :)

I have also looked into the batch geocoding (the Geocode tab) but I think I have to pass on that one.

There are only so many days left until June 11 :(

 

Now I have to fix those double maps that shows when you use the (Mobile-)Person map mod... But that's for the weekend (or after)

And the heatmap... 😄

 

Regards,

Erik

Share this post


Link to post
Share on other sites
DelG

My initial concern when this Google issue arose is if we switch to another map interface will we be able to retain all the current geo-codes and/or will the replacement (ex. OSM) also have a geo-code function? I cannot envision having to manually recode all geo locations! I do not currently understand how geo-codes are stored in TNG databases (if at all?). Thanks for any insight.

Share this post


Link to post
Share on other sites
XerxX

Hi DelG,

Do not worry! Rest assured that all your places will show fine in the OSM interface also.

Longitude and Latidude are standard.

I have some 5400 places with long and lat - I'm not going to re-do that (my editors would go on strike ;) )

 

The geocode function (as it's called in the OL scripts, anyway) gives the longitude and latidtude coordinates when given a (partial) name of a place

See the image sequence above. All data is stored as before. And is read as before.

I will not, however, do anything about the batch geocoding (done under the "Geocode" tab) until maybe after all the rest is done. That tab will not be present when there is no Google key.

 

I hope you can relax now,

Erik

Share this post


Link to post
Share on other sites
XerxX

Report:

Regarding the map on getperson.php:

I have removed the (Mobile) Person Map mod and replaced it with a simple toggle function, it does not make double maps...

It's not as sophisticated as the map mod but I didn't have to spend hours (days?) trying to find - I suspect - a trigger that fires twice, maybe because it "bubbles" up through the "command-chain". (I don't know how to express that, but it's a JS thing I have had bad experiences of...)

 

Opened map:

open.jpg

 

Closed map:

closed.jpg

 

You can try it here for example: https://xerxx.se/getpersonOSM.php?personID=I2635&tree=tredNr2

(Any name will open a new getperson w/ OSM-map, a magnifying glass opens an OSM-mapped place)

 

Heatmaps is next in line, and the I have to check the "Add more pins" mod....

(And then there are three private custom map mods)

 

/Erik

Share this post


Link to post
Share on other sites
manofmull

Erik

Like many TNG users here, I appreciate your work with OSM and look forward to the end result.

From your website link event map, I notice two things in the "pin box" (right side of the map).

1. Places are not hyperlinked (Mapplace To Link mod)

2. The pins are pointing to googlemaps as in my TNG11.1.2 setup

 

Michael

Share this post


Link to post
Share on other sites
XerxX

Thanks Michael,

The answers are very simple ;)

1) The Mapplace to link mod works just fine but it's not active at my site if you're not logged in. (I save a lot of goodies for my members :) )

2) Yes and for two reasons:

a) I didn't have to modify that code

b) Those maps are free to show (simple link - not through the API)

And I also kept the Google Earth links for the same reasons.

 

Best regards,

Erik

Share this post


Link to post
Share on other sites
XerxX

And I have managed to make a very basic heatmap.

Nothing but the "heats" and I'm not sure I do it correctly - the "weight" of each place is missing or something.

But I translate my database data into the map anyway. This one shows births per parish in Örebro county, Sweden.

https://xerxx.se/heatmap_TEST.php

 

Now I'll relax during the weekend!

And I wish you a pleasant one also,

Erik

 

Share this post


Link to post
Share on other sites
XerxX

Hi all,

A TEST-mod can be ready in a few days. So if anyone is interested in this mod, you are welcome to TEST it. I'll be back here when it's ready.

You need a TEST-environment (perferably a localhost, i guess) where the Google API key kan be removed.

 

Heatmaps are a problem!

I can get them to show data as expected but the interactions... I can't change them and they are set opposite to what we are used to!

I found an example that could be used almost without modifications.

- In these maps you click at the cluster-circle and it disappears to show the collected markers. (In the Google map you zoom in)

- In these maps you click the marker and nothing happens. (In the Google maps the name of the place is shown)

 

If you want to see examples, you can go here:

https://xerxx.se/heatmap_OSM.php?tree=tredNr2&psearch=Örebro län

for a "plain" heatmap, or here:

https://xerxx.se/heatmap_OSM2.php?tree=tredNr2&psearch=Örebro län

for a more "glowing" one.

Do you prefer one before the other?

 

I've now spent too many hours trying to solve that interaction problems and I can't find _explained_ examples.

There are only so few days left until June 11 and I have to "save" my site... I have three custom maps I haven't began to work on yet.

The API is too complex to comprehend in a few days (that it actually is) and implement it completely into TNG.

So I have compiled and modified examples - a lot of code is total mystery to me (esp the heatmaps) but what to do? I want maps at my site!

I have to stop working on this mod now and start testing to make sure that I can use it at my site. Even if it's not absolutely complete.

 

Regards,

Erik

Share this post


Link to post
Share on other sites
XerxX

Hello All,

In a few hours I have to leave and will not be avilable until late Friday afternoon.

 

But as this map thing is urgent (at least for me) I have prepared three BETA TEST mods and release them today, trying to not delay it:

v 11.1.2.beta1 and v 12.0.0.beta1 install fine in my TEST TNG 11.1.2 and 12.0.0 resp. They coop fine with my own Public mods (and e few others).

v 10.0.0.beta1 is = 11.1.2.beta1 but everything "heatmap" is removed from the .cfg file. It has NOT been installed (I have no TNG v10...)

They do not conflict with Google Maps 15 v 10.1.0.4 or Google Maps Add 4 more Place Levels v 10.1.0.1

They do conflict with Person Map and Mobile Ind Page Person Map mods! I have made a substitution (a simple open/close function) in the mod.

 

ALL questions regarding those mods should be posted HERE in this thread!

As well as solutions.

That way we will all benefit from questions and answers and...

... if we all help eachother, the development/testing will go much quicker.

And in the end we may have a really good mod - community-made! (In eleven days? Is it possible? Let's find out ;) )

 

There are only TWELVE DAYS left until the maps stop working...

The v 11 mod does not install at my live site (too many personal mods 😄 ) so I have to work on that. And three custom maps also...

So I'm sorry: I will not be able to give support in a personal way: Only through this thread. Please respect that.

 

Here is the link to the Wiki page:

https://tng.lythgoes.net/wiki/index.php?title=OpenStreetMap_BETA

Edit: (It's not restricted)

REMEMBER to read the READ-ME file: It's IMPORTANT (this is a BETA TEST mod - okay?)

 

/Erik

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×