From b04b015a5d988834712c05833a6b4881924ad18b Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Mon, 11 Sep 2017 22:10:24 +0200 Subject: [PATCH] Add openlayers 3 api, move extra layers to config, closes #27, closes #34 --- README.md | 2 +- config.default.php | 23 ++- css/main.css | 91 +++++++++ helpers/config.php | 14 +- images/marker-gold.png | Bin 0 -> 724 bytes images/marker-green.png | Bin 0 -> 696 bytes images/marker-red.png | Bin 0 -> 677 bytes images/marker-white.png | Bin 0 -> 359 bytes index.php | 22 +-- js/api_gmaps.js | 39 ++-- js/api_openlayers.js | 117 +++++++----- js/api_openlayers3.js | 411 ++++++++++++++++++++++++++++++++++++++++ js/main.js | 103 ++++++---- 13 files changed, 677 insertions(+), 145 deletions(-) create mode 100644 images/marker-gold.png create mode 100644 images/marker-green.png create mode 100644 images/marker-red.png create mode 100644 images/marker-white.png create mode 100755 js/api_openlayers3.js diff --git a/README.md b/README.md index c6df1ca..5cea457 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Together with a dedicated [μlogger mobile client](https://github.com/bfabiszews - multiple users - user authentication - Google Maps API v3 -- OpenLayers v2 (OpenStreet and other layers) +- OpenLayers v2 or v3 (OpenStreet and other layers) - ajax - user preferences stored in cookies - simple admin menu diff --git a/config.default.php b/config.default.php index 4a6a6c1..7a891e3 100755 --- a/config.default.php +++ b/config.default.php @@ -21,19 +21,18 @@ // Copy it to config.php and customize // default map drawing framework -// (gmaps = google maps, openlayers = openlayers/osm) -//$mapapi = "gmaps"; -$mapapi = "openlayers"; +//$mapapi = "gmaps"; // google maps +//$mapapi = "openlayers"; // openlayers 2 +$mapapi = "openlayers3"; // openlayers 3+ + +// openlayers additional map layers in XYZ format +// name => url +$ol_layers['OpenCycleMap'] = 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey='; // api key needed +$ol_layers['OpenTopoMap'] = 'https://{a-c}.tile.opentopomap.org/{z}/{x}/{y}.png'; +$ol_layers['ESRI'] = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'; +$ol_layers['UMP'] = 'http://{1-3}.tiles.ump.waw.pl/ump_tiles/{z}/{x}/{y}.png'; +$ol_layers['Osmapa.pl'] = 'http://{a-c}.tile.openstreetmap.pl/osmapa.pl/{z}/{x}/{y}.png'; -// openlayers additional map layers -// OpenCycleMap (0 = no, 1 = yes) -$layer_ocm = 1; -// MapQuest-OSM (0 = no, 1 = yes) -$layer_mq = 1; -// osmapa.pl (0 = no, 1 = yes) -$layer_osmapa = 1; -// UMP (0 = no, 1 = yes) -$layer_ump = 1; // default coordinates for initial map $init_latitude = 52.23; diff --git a/css/main.css b/css/main.css index ed73ff8..4e5563c 100755 --- a/css/main.css +++ b/css/main.css @@ -322,4 +322,95 @@ button { @keyframes blink { 50% { opacity: 0; } +} + +/* openlayers 3 popup */ +.ol-popup { + position: absolute; + background-color: white; + -webkit-filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); + filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); + padding: 15px; + border-radius: 10px; + border: 1px solid #cccccc; + bottom: 12px; + left: -50px; + min-width: 280px; +} +.ol-popup:after, .ol-popup:before { + top: 100%; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; +} +.ol-popup:after { + border-top-color: white; + border-width: 10px; + left: 48px; + margin-left: -10px; +} +.ol-popup:before { + border-top-color: #cccccc; + border-width: 11px; + left: 48px; + margin-left: -11px; +} +.ol-popup-closer { + text-decoration: none; + position: absolute; + top: 2px; + right: 8px; +} +.ol-popup-closer:after { + content: "✖"; +} + +#switcher { + display: none; + position: absolute; + bottom: 12px; + left: 10px; + min-width: 200px; +} +.ol-layerswitcher { + margin: 1px; + color: #fff; + background-color: rgba(0, 60, 136, .5); + border: none; + border-radius: 2px; + font-family: sans-serif; + font-weight: bold; + font-size: .9em; + padding: 0.5em; +} +.ol-layerswitcher:hover { + background-color: rgba(0, 60, 136, .7) +} +.ol-layerswitcher label { + display: block; + clear: both; + margin: .5em 0; + cursor: pointer; +} +.ol-layerswitcher label:hover { + color: #c8dcf2; +} +.ol-layerswitcher input { + margin-right: 1em; +} +label.ol-datalayer { + margin-top: 1.5em; +} +.ol-datalayer ~ .ol-datalayer { + margin-top: .5em; +} +.ol-switcher-button { + top: 6.6em; + left: .5em; +} +.ol-touch .ol-switcher-button { + top: 10em; } \ No newline at end of file diff --git a/helpers/config.php b/helpers/config.php index 4cc3361..0c8658d 100644 --- a/helpers/config.php +++ b/helpers/config.php @@ -37,14 +37,7 @@ static $gkey = null; // openlayers additional map layers - // OpenCycleMap (0 = no, 1 = yes) - static $layer_ocm = 1; - // MapQuest-OSM (0 = no, 1 = yes) - static $layer_mq = 1; - // osmapa.pl (0 = no, 1 = yes) - static $layer_osmapa = 1; - // UMP (0 = no, 1 = yes) - static $layer_ump = 1; + static $ol_layers = []; // default coordinates for initial map static $init_latitude = 52.23; @@ -114,10 +107,7 @@ if (isset($mapapi)) { self::$mapapi = $mapapi; } if (isset($gkey)) { self::$gkey = $gkey; } - if (isset($layer_ocm)) { self::$layer_ocm = $layer_ocm; } - if (isset($layer_mq)) { self::$layer_mq = $layer_mq; } - if (isset($layer_osmapa)) { self::$layer_osmapa = $layer_osmapa; } - if (isset($layer_ump)) { self::$layer_ump = $layer_ump; } + if (isset($ol_layers)) { self::$ol_layers = $ol_layers; } if (isset($init_latitude)) { self::$init_latitude = $init_latitude; } if (isset($init_longitude)) { self::$init_longitude = $init_longitude; } if (isset($dbhost)) { self::$dbhost = $dbhost; } diff --git a/images/marker-gold.png b/images/marker-gold.png new file mode 100644 index 0000000000000000000000000000000000000000..82dd7c4e360c669a1a90aeda01c9d26a0b3f88d8 GIT binary patch literal 724 zcmV;_0xSKAP)X1^@s6IQ*`u0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!c1c7*RCwBAWIzQ1Dk}U5fk8^~TAG3e z3JQE+!3PgMFF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Z(wIWVhV3hY)4z?X1^@s6IQ*`u0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!M@d9MRCwB)lS^n5Q51&1Bn7ikCnADE zArz5TL6SwmLXiY?p&+CRq9B^O@UamEY2B6X#7$FlVFgLLQmSC;rub?GL_-Bhs#fbG zIAYaQ#SU7bRiWNH&EsY|O+$aUBy%4Bz32SrxTu7-aW&Ds4IF9m5%8~?HyS_T)fCx* zcMKZ8hzXNfOmHd5k@GFYk8eiPR^SM87W!Udo=bB^d?rc+ThV zHdc}xen8UI7h>v|s9U`?oFpv&+Aa;HBBa#U#GZkBlU7ca82UigA=%s0 zz*`gjwYm6qE=h1R$EawiQ7y((%_)XP?nb^^3GO8tS+#zN{{jpEQGmwfe$yQ@00000 LNkvXXu0mjfk?u0n literal 0 HcmV?d00001 diff --git a/images/marker-white.png b/images/marker-white.png new file mode 100644 index 0000000000000000000000000000000000000000..6e70481753a08b4b4b47b682e62c0b4e7c6ca71f GIT binary patch literal 359 zcmV-t0hs=YP)X1^@s6IQ*`u0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUz2}wjjRCwC#RIv?%Fc2gp0~jW-SRfvO z2@qu}lr~#r14i%&WCO?qkdg+cOlLMA|HzRdgE0H)UaD~{dw0gfSdbuk+%N_FFiYsGk3mIIm!; + var init_latitude = ; + var init_longitude = ; var lang = ; var admin = isAdmin()) ?>; var auth = 'isAuthenticated()) ? $auth->user->login : "null" ?>'; var pass_regex = ; - - - - - - - - isAdmin()): ?> @@ -106,7 +95,7 @@ - + '; } - popup = + var popup = '