From 268352c1ed382f2b9a18e70c7e6eaced9a950336 Mon Sep 17 00:00:00 2001 From: Sagarpreet Chadha Date: Thu, 14 Nov 2019 03:27:42 +0530 Subject: [PATCH] Full screen button added in inline maps, Multiple maps in Wiki page works now. (#6699) * full screen added * working on wiki page * code refactoring * console logs removed * inline map layers are ON by default now * version bump of LEL to add new Layers * api changed tagslocation init * api taglocations changed * popup content changed --- app/api/srch/search.rb | 4 +- app/assets/javascripts/leaflet_helper.js | 36 ++++---- app/assets/javascripts/wikis.js | 6 +- app/models/doc_result.rb | 4 +- app/services/search_service.rb | 2 +- app/views/layouts/_header.html.erb | 3 + app/views/layouts/application.html.erb | 10 +-- app/views/map/_inlineLeaflet.html.erb | 16 ++-- app/views/map/_mapDependencies.html.erb | 13 ++- app/views/map/_plainInlineLeaflet.html.erb | 99 ++++------------------ package.json | 5 +- yarn.lock | 75 ++++++++++++++-- 12 files changed, 145 insertions(+), 128 deletions(-) diff --git a/app/api/srch/search.rb b/app/api/srch/search.rb index 61bec709df..d1525929f5 100644 --- a/app/api/srch/search.rb +++ b/app/api/srch/search.rb @@ -298,7 +298,6 @@ class Search < Grape::API end # Request URL should be /api/srch/taglocations?nwlat=200.0&selat=0.0&nwlng=0.0&selng=200.0[&tag=awesome] - # Note: Query(QRY as above) must have latitude and longitude as query=lat,lon desc 'Perform a search of documents having nearby latitude and longitude tag values', hidden: false, is_array: false, nickname: 'search_tag_locations' @@ -317,6 +316,8 @@ class Search < Grape::API doc_type: 'PLACES', doc_url: model.path(:items), doc_title: model.title, + doc_author: model.user.username, + doc_image_url: !model.images.empty? ? model.images.first.path : 0, score: model.answers.length, latitude: model.lat, longitude: model.lon, @@ -330,7 +331,6 @@ class Search < Grape::API end # Request URL should be /api/srch/nearbyPeople?nwlat=200.0&selat=0.0&nwlng=0.0&selng=200.0[&tag=awesome&sort_by=recent] - # Note: Query(QRY as above) must have latitude and longitude as query=lat,lon desc 'Perform a search to show people nearby a given location', hidden: false, is_array: false, nickname: 'search_nearby_people' diff --git a/app/assets/javascripts/leaflet_helper.js b/app/assets/javascripts/leaflet_helper.js index 504e64c936..2cc300bda0 100644 --- a/app/assets/javascripts/leaflet_helper.js +++ b/app/assets/javascripts/leaflet_helper.js @@ -8,21 +8,6 @@ return map ; } - - function setupFullScreen(map , lat , lon) { - map.addControl(new L.Control.Fullscreen()); // to go full-screen - map.on('fullscreenchange', function () { - if (map.isFullscreen()) { - map.options.minZoom = 3 ; - } - else { - map.options.minZoom = 1 ; - map.panTo(new L.LatLng(lat,lon)); - } - }); - } - - function PLmarker_default(){ L.Icon.PLmarker = L.Icon.extend({ options: { @@ -65,7 +50,7 @@ }); } - function contentLayerParser(map,markers_hash, map_tagname) { + function contentLayerParser(map, markers_hash, map_tagname) { var NWlat = map.getBounds().getNorthWest().lat ; var NWlng = map.getBounds().getNorthWest().lng ; var SElat = map.getBounds().getSouthEast().lat ; @@ -82,13 +67,19 @@ for (i = 0; i < data.items.length; i++) { var url = data.items[i].doc_url; var title = data.items[i].doc_title; + var author = data.items[i].doc_author; + var image_url = data.items[i].doc_image_url; var default_url = PLmarker_default(); var mid = data.items[i].doc_id ; var m = L.marker([data.items[i].latitude, data.items[i].longitude], {icon: default_url}).bindPopup("" + title + "") ; if(markers_hash.has(mid) === false){ - m.addTo(map).bindPopup("" + title + "") ; + if(image_url) { + m.addTo(map).bindPopup("

" + "Title: " + title + "
Author: " + author + "
" + "" + "Read more..." + "
" ) ; + } else { + m.addTo(map).bindPopup("Title: " + title + "
Author: " + author + "
" + "" + "
Read more..." + "
" ) ; + } markers_hash.set(mid , m) ; } } @@ -105,8 +96,14 @@ L.tileLayer('https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png').addTo(map) ; + var oms = omsUtil(map, { + keepSpiderfied: true, + circleSpiralSwitchover: 0 + }); + L.LayerGroup.EnvironmentalLayers({ include: layers, + embed: true, }).addTo(map); if(typeof mainLayer !== "undefined" && mainLayer !== ""){ @@ -148,6 +145,11 @@ attribution: '© OpenStreetMap contributors' }).addTo(map) ; + var oms = omsUtil(map, { + keepSpiderfied: true, + circleSpiralSwitchover: 0 + }); + L.LayerGroup.EnvironmentalLayers({ hash: !!sethash, }).addTo(map); diff --git a/app/assets/javascripts/wikis.js b/app/assets/javascripts/wikis.js index ba2ea23b80..da653f2dc0 100644 --- a/app/assets/javascripts/wikis.js +++ b/app/assets/javascripts/wikis.js @@ -26,9 +26,9 @@ function setupWiki(node_id, title, raw, logged_in) { }); $('#content').hide(); } else { - $('#content').html(shortCodePrompt($('#content')[0], { - submitUrl: '/wiki/replace/' + node_id - })); + // $('#content').html(shortCodePrompt($('#content')[0], { + // submitUrl: '/wiki/replace/' + node_id + // })); postProcessContent(); addDeepLinks($('#content')); } diff --git a/app/models/doc_result.rb b/app/models/doc_result.rb index df9b87cdf5..93a1dd71df 100644 --- a/app/models/doc_result.rb +++ b/app/models/doc_result.rb @@ -1,6 +1,6 @@ # A DocResult is an individual return item for a document (web page) search class DocResult - attr_accessor :doc_id, :doc_type, :doc_url, :doc_title, :doc_score, :latitude, :longitude, :blurred, :category + attr_accessor :doc_id, :doc_type, :doc_url, :doc_title, :doc_score, :latitude, :longitude, :blurred, :category, :doc_author, :doc_image_url def initialize(args = {}) @doc_id = args[:doc_id] @@ -8,6 +8,8 @@ def initialize(args = {}) @doc_url = args[:doc_url] @doc_title = args[:doc_title] @doc_score = args[:doc_score] + @doc_author = args[:doc_author] + @doc_image_url = args[:doc_image_url] @latitude = args[:latitude] @longitude = args[:longitude] @blurred = args[:blurred] diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 3ceca6f637..d06a850446 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -154,7 +154,7 @@ def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, so else items.order(Arel.sql("created #{order_direction}")) .limit(limit) - end + end end # Search nearby people with respect to given latitude, longitute and tags diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index c856ad980f..48b2826a7a 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -176,6 +176,9 @@ <%= render partial: "layouts/signupLoginModal" %> + + + + .leaflet-popup-content { + width: 800px !important; + } - - - - + + diff --git a/app/views/map/_inlineLeaflet.html.erb b/app/views/map/_inlineLeaflet.html.erb index 27a65399bc..8fe57cd4c4 100644 --- a/app/views/map/_inlineLeaflet.html.erb +++ b/app/views/map/_inlineLeaflet.html.erb @@ -8,6 +8,9 @@ #postOnMap<%= unique_id %> { margin-top: 5px; } + .leaflet-popup-content { + width: auto !important; + }
@@ -19,10 +22,13 @@ diff --git a/package.json b/package.json index 9aeb654e22..7e15d7bb59 100644 --- a/package.json +++ b/package.json @@ -40,11 +40,12 @@ "jquery-validation": "^1.19.1", "jsdiff": "components/jsdiff#~3.4.0", "junction": "theleagueof/junction#*", - "leaflet": "^0.7.3", - "leaflet-environmental-layers": "git://github.com/publiclab/leaflet-environmental-layers#fkl", + "leaflet": "^1.5.1", + "leaflet-environmental-layers": "^2.0.5", "leaflet-blurred-location": "^1.3.0", "leaflet-fullhash": "github:sagarpreet-chadha/leaflet-fullHash", "leaflet-spin": "1.1.0", + "leaflet.fullscreen": "1.6.0", "marked": "^0.7.0", "megamark": "~3.3.0", "moment": "~> 2.24.0", diff --git a/yarn.lock b/yarn.lock index 962fcb7a6a..c11eec3b2b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1313,6 +1313,11 @@ duplexer2@~0.1.4: dependencies: readable-stream "^2.0.2" +earcut@^2.1.3: + version "2.2.1" + resolved "https://registry.yarnpkg.com/earcut/-/earcut-2.2.1.tgz#3bae0b1b6fec41853b56b126f03a42a34b28f1d5" + integrity sha512-5jIMi2RB3HtGPHcYd9Yyl0cczo84y+48lgKPxMijliNQaKAHEZJbdzLmKmdxG/mCdS/YD9DQ1gihL8mxzR0F9w== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -3185,9 +3190,18 @@ leaflet-blurred-location@^1.2.5, leaflet-blurred-location@^1.3.0: jquery "^3.2.1" leaflet "^1.3.3" -"leaflet-environmental-layers@git://github.com/publiclab/leaflet-environmental-layers#fkl": - version "2.0.1" - resolved "git://github.com/publiclab/leaflet-environmental-layers#c4126395692a9b6e6e532b349cf240728afa7994" +"leaflet-blurred-location@git://github.com/publiclab/leaflet-blurred-location.git#main": + version "1.3.0" + resolved "git://github.com/publiclab/leaflet-blurred-location.git#1bff37cb96518bd87192277b14c290cba3c138ba" + dependencies: + haversine-distance "^1.1.4" + jquery "^3.2.1" + leaflet "^1.3.3" + +leaflet-environmental-layers@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/leaflet-environmental-layers/-/leaflet-environmental-layers-2.0.5.tgz#c35cd704102a049803db58df7ba73dcea02dafc0" + integrity sha512-1zQl9973UM1t2QmqWaOxm5mHkhRRf7K23BN2GSkFEy/YHKZbszjAths206NEcNuR7FkX22v+5h6O/D1oyMw3Sw== dependencies: jquery "^3.3.1" leaflet "^1.3.1" @@ -3197,6 +3211,7 @@ leaflet-blurred-location@^1.2.5, leaflet-blurred-location@^1.3.0: leaflet-providers "^1.1.17" leaflet-spin "1.1.0" leaflet.blurred-location-display "^1.1.0" + leaflet.glify "github:robertleeplummerjr/Leaflet.glify#aa2b356" "leaflet-fullhash@github:sagarpreet-chadha/leaflet-fullHash": version "1.0.0" @@ -3227,14 +3242,29 @@ leaflet.blurred-location-display@^1.1.0: jquery "^3.3.1" leaflet-blurred-location "git://github.com/publiclab/leaflet-blurred-location#main" +leaflet.fullscreen@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/leaflet.fullscreen/-/leaflet.fullscreen-1.6.0.tgz#daad9a6e07c8bdbca8e5af7e3d50272d31b0226a" + integrity sha512-Mr6STMeyKSfJ1CsKFcPZOm425LOe0c/6EHh0AK93GiTvteTAMFmO/oFDNe+0p1mk4+8yeGLcYgaXTSzPveEGhA== + +"leaflet.glify@github:robertleeplummerjr/Leaflet.glify#aa2b356": + version "2.1.0" + resolved "https://codeload.github.com/robertleeplummerjr/Leaflet.glify/tar.gz/aa2b356eccd4f120f713abd5f24800e06fb3fbf7" + dependencies: + earcut "^2.1.3" + leaflet "^1.3.4" + point-in-polygon "^1.0.1" + polygon-lookup "^2.4.0" + rbush "^2.0.2" + leaflet@*, leaflet@^1.3.1, leaflet@^1.3.3: version "1.4.0" resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.4.0.tgz#d5f56eeb2aa32787c24011e8be4c77e362ae171b" -leaflet@^0.7.3: - version "0.7.7" - resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-0.7.7.tgz#1e352ba54e63d076451fa363c900890cb2cf75ee" - integrity sha1-HjUrpU5j0HZFH6NjyQCJDLLPde4= +leaflet@^1.3.4, leaflet@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.5.1.tgz#9afb9d963d66c870066b1342e7a06f92840f46bf" + integrity sha512-ekM9KAeG99tYisNBg0IzEywAlp0hYI5XRipsqRXyRTeuU8jcuntilpp+eFf5gaE0xubc9RuSNIVtByEKwqFV0w== levn@^0.3.0, levn@~0.3.0: version "0.3.0" @@ -3282,6 +3312,11 @@ lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" +lodash@^4.14.2: + version "4.17.15" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" + integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + lodash@~0.9.2: version "0.9.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-0.9.2.tgz#8f3499c5245d346d682e5b0d3b40767e09f1a92c" @@ -4110,6 +4145,20 @@ pngjs@^3.3.3: version "3.3.3" resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.3.3.tgz#85173703bde3edac8998757b96e5821d0966a21b" +point-in-polygon@1.0.1, point-in-polygon@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/point-in-polygon/-/point-in-polygon-1.0.1.tgz#d59b64e8fee41c49458aac82b56718c5957b2af7" + integrity sha1-1Ztk6P7kHElFiqyCtWcYxZV7Kvc= + +polygon-lookup@^2.4.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/polygon-lookup/-/polygon-lookup-2.5.0.tgz#4f545dd4d8af99c44ca7ffe3b5c46bf99845507b" + integrity sha512-0Xs8Cvudz7M7jXGZrxAJ7tO+N4K+ZyibgvcJBy9nr9kGfa7Nbk3iZViZWPuB4T/IrsxLzl9xOt4+mZlnioye6g== + dependencies: + lodash "^4.14.2" + point-in-polygon "1.0.1" + rbush "^2.0.2" + popper.js@^1.16.0: version "1.16.0" resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.0.tgz#2e1816bcbbaa518ea6c2e15a466f4cb9c6e2fbb3" @@ -4340,6 +4389,11 @@ qs@~6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" +quickselect@^1.0.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.1.1.tgz#852e412ce418f237ad5b660d70cffac647ae94c2" + integrity sha512-qN0Gqdw4c4KGPsBOQafj6yj/PA6c/L63f6CaZ/DCF/xF4Esu3jVmKLUDYxghFx8Kb/O7y9tI7x2RjTSXwdK1iQ== + quote-stream@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/quote-stream/-/quote-stream-1.0.2.tgz#84963f8c9c26b942e153feeb53aae74652b7e0b2" @@ -4363,6 +4417,13 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" +rbush@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.2.tgz#bb6005c2731b7ba1d5a9a035772927d16a614605" + integrity sha512-XBOuALcTm+O/H8G90b6pzu6nX6v2zCKiFG4BJho8a+bY6AER6t8uQUZdi5bomQc0AprCWhEGa7ncAbbRap0bRA== + dependencies: + quickselect "^1.0.1" + rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"