Skip to content

Instantly share code, notes, and snippets.

@nabeelio
Last active August 15, 2020 08:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabeelio/8b7ab29fb67dfe27284d63d7136388dc to your computer and use it in GitHub Desktop.
Save nabeelio/8b7ab29fb67dfe27284d63d7136388dc to your computer and use it in GitHub Desktop.
phpVMS v2 Maps

Updating phpVMS Legacy to OSM

This updates the legacy phpVMS install to use Leaflet mapping library to replace the Google Maps integration. Using Leaflet, the base maps is interchangeable, the default setup uses the OpenStreetMap "Mapnik" style base layer. This can be changed (see the changes for MAP_TYPE below). I recommend reading through the entire pull request just to familiarize yourself with the changes.

When viewing the diffs below, red are the lines to delete, and green would be to add.


Copy new files:

Download the phpvms_v2 repository zip file into a new folder, and copy the following files and place them in the same path on your site:

  • lib/js/leaflet
  • lib/js/base_map.js
  • lib/js/acarsmap.js (if you've made changes to this file, backport them if needed)

Skin Modifications

Place it before before the </head> tag in your skin (default is /lib/skins/crystal/layout.tpl). If you're using a different skin, then update the same files in that skin. If you have .php files instead of .tpl, then also update those respective files.

<link rel="stylesheet" href="<?php echo SITE_URL?>/lib/js/leaflet/leaflet.css" />
<script src="<?php echo SITE_URL?>/lib/js/leaflet/leaflet.js"></script>
<script src="<?php echo SITE_URL?>/lib/js/leaflet/leaflet-providers.js"></script>
<script src="<?php echo SITE_URL?>/lib/js/leaflet/Leaflet.Geodesic.js"></script>

Configuration Modifications

In your core/app.config.php and core/local.config.php, replace the following:

MAP_TYPE

The base map can be customized and changed out to different providers.

Find:

Config::Set('MAP_TYPE', 'G_PHYSICAL_MAP');

and replace with:

Config::Set('MAP_TYPE', 'OpenStreetMap.Mapnik');

You can also change OpenStreetMap.Mapnik to a different basemap. Those options can be found here:

http://leaflet-extras.github.io/leaflet-providers/preview

To use a base map that requires an API key, see the notes in libs/js/base_map.js.

MAP_ZOOM_LEVEL

The scaling for zoom is different between Google Maps and the Leaflet zoom system. Find:

Config::Set('MAP_ZOOM_LEVEL', 12);

and replace with:

Config::Set('MAP_ZOOM_LEVEL', 5);

Template Modifications

Follow the instructions here, red are lines to remove, green are lines to add. Dark green are changes to lines.

1. core/templates/acarsmap.tpl

Note: it's probably best to just overwrite the entire file, and then copy any of your changes back into it. Otherwise, the diffs are located here:

View the changes for acarsmap.tpl

2. core/templates/route_map.tpl

Note: it's probably best to just overwrite the entire file, and then copy any of your changes back into it. Otherwise, the diffs are located here:

View the changes for route_map.tpl

And finally

Damn you, Google.

@Locke01021988
Copy link

I hava a question. I got the new map in the crystal skin and it works fine for me. But if i switch to the crewcenter skin, there is just a white window where the map should be. I think it´s the layout data of the crew center skin. Could you explain to me, where in this data i have to fill in the following:

+<script src="/lib/js/leaflet/leaflet.js"></script> +<script src="/lib/js/leaflet/leaflet-providers.js"></script> +<script src="/lib/js/leaflet/Leaflet.Geodesic.js"></script>

Thank you.

@maxdyba
Copy link

maxdyba commented Sep 2, 2018

Same issue here, I co-developed the CC skin and I can't find a solution myself.

@avs-code
Copy link

avs-code commented Oct 31, 2018

@nabeel Instrucctions to /pireps/routesmap or /core/templates/flown_routes_map.tpl are missing.
I going to try it and write again here if I have success.

@MWE001
Copy link

MWE001 commented Dec 8, 2018

Did them last 2 maps instructions ever get figured out?

@amirmahdioun
Copy link

Hi ,
I did all the instructions but doesn't work
please help me :(

@wimatte
Copy link

wimatte commented May 9, 2020

It works for us but it would be lovely if Nabeel could chip in with some indications about how to modify /pireps/routesmap and /core/templates/flown_routes_map
Pretty Please.....

@nabeelio
Copy link
Author

The other changes are in the diffs that are linked above, if you scroll down

@amirmahdioun
Copy link

I do all that
The map has been changed but is doesn't show any information on it when we are on flight, seems it removes all data or doesn't sync them

@wimatte
Copy link

wimatte commented Jun 5, 2020

I'm sorry Nabeelio, I wasn't clear. Everything is working wonderfully in the frontend, I was referring to the Admin side of things, route_map on Pirep preview specifically. Can't seem to get the Map to show with the code available and keep getting this error:

Can't access Lexical declaration declaration "createmap" before initialization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment