Skip to content

Instantly share code, notes, and snippets.

@nabeelio nabeelio/maps.md
Last active Dec 8, 2018

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented May 18, 2018

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.

@XiRealizeX

This comment has been minimized.

Copy link

commented Sep 2, 2018

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

@arv187

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Dec 8, 2018

Did them last 2 maps instructions ever get figured out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.