Skip to content

Commit

Permalink
Allow retrieving base MVT style from another host
Browse files Browse the repository at this point in the history
  • Loading branch information
gberaudo committed Jun 18, 2020
1 parent 842488e commit 6be2b22
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,11 @@ const MainController = function(
// Super hack because we do not have access to the offline button controller
this.map_.superHackIsItOKToSaveOffline = () => {
const isIOS = document.location.search.includes("localforage=ios") || document.location.search.includes("fakeios");
return !isIOS || !this.backgroundLayerMgr_.get(this.map).getMapBoxMap
if (isIOS) {
const layer = this.backgroundLayerMgr_.get(this.map);
return layer && !layer.getMapBoxMap;
}
return true;
};

/**
Expand Down
19 changes: 15 additions & 4 deletions geoportal/geoportailv3_geoportal/static-ngeo/js/apps/main.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="https://www.geoportail.lu/static/images/apple-icon-72x72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://www.geoportail.lu/static/images/apple-icon-114x114-precomposed.png" />
<script>
var dev = document.location.href.indexOf('dev/main') !== -1;
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js' + (dev ? '?dev' : ''))
.then(function() { console.log("Service Worker Registered"); });
var dev = document.location.href.indexOf('dev/main') !== -1;
var fakeios = document.location.href.indexOf('fakeios') !== -1;
if (fakeios) {
navigator.serviceWorker.getRegistrations().then(
function(registrations) {
for(let registration of registrations) {
registration.unregister()
}
}
);
} else {
navigator.serviceWorker
.register('/sw.js' + (dev ? '?dev' : ''))
.then(function() { console.log("Service Worker Registered"); });
}
}
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ const ls_ = window.localStorage;
const LS_KEY_EXPERT = 'expertStyling';
const LS_KEY_MEDIUM = 'mediumStyling';
const LS_KEY_HILLSHADE = 'hillshadeStyling';
export const defaultMapBoxStyle = 'https://vectortiles.geoportail.lu/styles/roadmap/style.json';

function getDefaultMapBoxStyleUrl() {
const searchParams = new URLSearchParams(document.location.search);
const embeddedServer = searchParams.get('embeddedserver');
const url = (embeddedServer ? 'http://' + embeddedServer : 'https://vectortiles.geoportail.lu') + '/styles/roadmap/style.json';
return url;
}
export const defaultMapBoxStyle = getDefaultMapBoxStyleUrl();
export const defaultMapBoxStyleXYZ = 'https://vectortiles.geoportail.lu/styles/roadmap/{z}/{x}/{y}.png';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const exports = class extends NgeoConfiguration {
*/
this.appMymaps_ = appMymaps;

const isMobile = location.search.includes('localforage=android') || location.search.includes('localforage=ios');
const isMobile = location.search.includes('localforage=android') || location.search.includes('localforage=ios') || location.search.includes('fakeios');

/**
* @type {number}
Expand Down
13 changes: 13 additions & 0 deletions prepare_ios_mvt_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/data/hillshade-lu.json

rm -rf ios_bundle; mkdir ios_bundle; cd ios_bundle
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/data/omt-geoportail-lu.json
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/fonts/Noto%20Sans%20Regular/0-255.pbf
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/fonts/Noto%20Sans%20Regular/256-511.pbf
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/fonts/Noto%20Sans%20Bold/0-255.pbf
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/fonts/Noto%20Sans%20Bold/256-511.pbf
wget --no-host-directories --force-directories https://vectortiles.geoportail.lu/styles/roadmap/style.json
sed 'sYhttps://vectortiles.geoportail.lu/data/omt-geoportail-lu.jsonYhttp://localhost:8765/data/omt-geoportail-lu.jsonYg' -i styles/roadmap/style.json
sed 'sYhttps://vectortiles.geoportail.lu/fonts/Yhttp://localhost:8765/fonts/Yg' -i styles/roadmap/style.json
wget http://download.geoportail.lu/index.php/s/o7ZmTx7ySpgZgF7/download -O omt-geoportail-lu.mbtiles

0 comments on commit 6be2b22

Please sign in to comment.