Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs#21327 edw_maps module #2

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1ab955d
refs#21327 edw_maps for mapbox
iuga-paula Dec 14, 2023
847b03e
refs#21327 fixed area's GeoJson, render map even if view has no results
iuga-paula Dec 15, 2023
541f49a
refs#21327 refactoring + styling
iuga-paula Dec 19, 2023
d7be8ca
refs#21327 unzip geoJson when installing module, code QA fixes
iuga-paula Jan 10, 2024
c7227bc
refs#21327 small fixes
iuga-paula Jan 10, 2024
478196c
refs#21327 added drupal/geofield dependency in composer.json
iuga-paula Jan 11, 2024
442f378
refs#21327 updated module specs
iuga-paula Jan 11, 2024
02b772b
refs#21327 fixed missing country borders file, add only countries wit…
iuga-paula Jan 11, 2024
86c2f87
refs#21327 handle logic exception for render, option to not render po…
iuga-paula Jan 11, 2024
9cb42f1
refs#21327 merge settings when using ajax filters
iuga-paula Jan 12, 2024
5551e8c
refs#21327 code qa fixes
iuga-paula Jan 12, 2024
81fed52
refs#21327 removed logging
iuga-paula Jan 12, 2024
705a30c
Merge branch 'main' into 21327-maps-module
iuga-paula Feb 26, 2024
b303275
refs#23054 extra features
iuga-paula Feb 26, 2024
6208009
refs#23054 fixed popups on hover for pins and countries
iuga-paula Feb 27, 2024
be5fbcb
refs#22552 option to redirect at country click
iuga-paula Apr 26, 2024
50f6fb9
refs#22552 cach unzip errors
iuga-paula Apr 26, 2024
ed4a103
refs #21327 allow overwriting properties and methods
calimanleontin May 2, 2024
39fafba
refs#22552 allow custom color for cartotile hover
iuga-paula May 15, 2024
a818a30
refs#21327 updated clear map source
iuga-paula May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/edw_document/src/Services/DocumentsBulkManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function loadEntityFromBulkFormKey($encodedKey, bool $isSearchApi = TRUE)
*
* @SuppressWarnings(PHPMD.ShortVariable)
*/
private function bulkForm(array $keyParts) {
protected function bulkForm(array $keyParts) {
// If there are 3 items, vid will be last.
$revisionId = (count($keyParts) === 3) ? array_pop($keyParts) : NULL;
// The first two items will always be langcode and ID.
Expand All @@ -108,7 +108,7 @@ private function bulkForm(array $keyParts) {
*
* @see ViewsBulkOperationsBulkForm::calculateEntityBulkFormKey()
*/
private function searchApiBulkForm(array $keyParts) {
protected function searchApiBulkForm(array $keyParts) {
// Drop first element (the value of the base field for this view result).
array_shift($keyParts);
// The first three items will always be the entity type, langcode and ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MeetingCloneSubscriber implements EventSubscriberInterface {
*
* @var \Drupal\edw_event\Services\MeetingService
*/
private $meetingService;
protected $meetingService;

/**
* Class constructor, injects the services.
Expand Down
5 changes: 5 additions & 0 deletions modules/edw_maps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vendor
composer.lock

# GeoJson file is too big for GitHub.
/assets/country_boundaries/country_polygon.geojson
113 changes: 113 additions & 0 deletions modules/edw_maps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# EDW Mapbox Integration for Drupal

## Description
This module is designed to integrate Mapbox, a leading mapping platform, into your Drupal-powered websites.
This module provides a range of features to enhance your website with interactive and customizable maps using *views*.

**Note:** This module requires a _Mapbox account and API key_.

## Prerequisites
* Geofields on your contents of type latitue/logitude or Geofield WKT

## Installation
Before enabling this module, make sure that the following modules are present in your codebase by adding them to your composer.json and running `composer update`:

```php
"require": {
"drupal/core": "^9.4 || ^10",
"drupal/geofield": "^1.41",
"ext-zip": "*",
"itamair/geophp": "^1.5"
}
```

## How to use

1. Enable the module.
2. Obtain a Mapbox API key [from your mapbox account](https://account.mapbox.com/), go to _/admin/config/system/edw_maps/settings_ and configure the module settings or add them in your _settings.local_ file:
```php
$config['edw_maps.settings']['token'] = 'pk.xxxxxxxxxxxxx';
$config['edw_maps.settings']['default_style_url'] = 'mapbox://styles/ccac-secretariat/cljcyeoxg000601plehvh667v';
```
3. Create a view block, select *EDW Mapbox Map* for format and *fields* for show.
4. Configure format settings: you need to select a GeoField as a source for pins/polygons display.
5. Easily embed maps into your Drupal content using a content block.

## How to style
1. To style markers use ``.edw-marker`` class in your css. You can choose a different icon or oen from the ``assets/icons`` folder:
```css
.edw-marker {
background-image: url('mapbox-icon.png');
background-size: cover;
width: 50px;
height: 50px;
border-radius: 50%;
cursor: pointer;
}
```
2. To style clusters use ``.edw-cluster-marker`` class in your css.

## Altering tooltip data
You can display a rendered entity in a tooltip or any other field.
You can alter the contents of the _rendered entity_ using ``edw_maps`` hooks:
* to alter pin popup data: ``hook_edw_maps_pin_tooltip_data_alter()``
* to alter country popup data: ``hook_edw_maps_country_tooltip_data_alter()``
* to alter area popup data: ``hook_edw_maps_area_tooltip_data_alter()``

## GEOFields examples
For pins - point:
- WKT format: ``POINT (10.0 51.0)``
- GeoJson format:
```JSON
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [10.0, 51.0]
},
"properties": {}
}
```

For areas - polygon:
- WKT format: ``POLYGON ((73.4 42.1, 79.0 42.1, 79.0 35.8, 73.4 35.8, 73.4 42.1))``
- GeoJson format:
```JSON
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[73.4, 42.1],
[79.0, 42.1],
[79.0, 35.8],
[73.4, 35.8],
[73.4, 42.1]
]
]
},
"properties": {}
}
```


## Key Features

1. **Interactive Maps:** Embed fully interactive maps on your Drupal site, allowing users to explore locations, zoom in/out, and interact with map features effortlessly.

2. **Custom Map Styles:** Leverage the flexibility of Mapbox's styling capabilities to create visually stunning and branded maps that match your website's design aesthetics.

3. **UN GIS support:** When displaying a map you can choose to render UN approved tiles: https://www.un.org/geospatial/mapsgeo/webservices. Keep in mind that "Carto Tile" cannot display pins.

4. **Dynamic Marker Placement:** Easily add markers to the map to highlight key points of interest. Customize markers with icons, colors, and pop-up information to convey valuable details.

5. **Marker clustering**

6. **Responsive Design:** Ensure a seamless experience across devices with responsive map designs that adapt to various screen sizes, enhancing usability for both desktop and mobile users.

7. **Drupal Configuration Integration:** Effortlessly configure and customize maps directly from the Drupal administration interface, providing administrators with a user-friendly experience.

8. **Open Source Compatibility:** Aligning with the principles of open-source development, this module integrates seamlessly with Drupal's ecosystem, fostering collaboration and community-driven improvements.


Binary file not shown.
1 change: 1 addition & 0 deletions modules/edw_maps/assets/icons/filter-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-gray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-orange.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-pink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-purple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions modules/edw_maps/assets/icons/mapbox-marker-icon-yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions modules/edw_maps/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "drupal/edw_maps",
"description": "This module provides Mapbox integration with views for custom and UN tiles",
"type": "drupal-module",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Paula Iuga",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"homepage": "https://github.com/eaudeweb/edw_modules",
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"require": {
"php": "^8",
"drupal/core": "^9.4 || ^10",
"drupal/geofield": "^1.41",
"ext-zip": "*",
"itamair/geophp": "^1.5"
}
}
2 changes: 2 additions & 0 deletions modules/edw_maps/config/install/edw_maps.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
token: ''
default_style_url: ''
10 changes: 10 additions & 0 deletions modules/edw_maps/config/schema/edw_maps.schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
edw_maps.settings:
type: config_object
label: 'Edw maps settings'
mapping:
token:
type: string
label: 'Token'
default_style_url:
type: string
label: 'Default Mapbox Style URL'
87 changes: 87 additions & 0 deletions modules/edw_maps/css/edw_mapbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.map-container {
width: 100%;
height: 600px;
}

@media screen and (max-width: 768px) {
.map-container {
height: 400px;
}
}

@media screen and (max-width: 480px) {
.map-container {
height: 300px;
}
}

.edw-marker {
background-image: url('../assets/icons/mapbox-marker-icon-yellow.svg');
background-size: contain;
width: 20px;
height: 28px;
cursor: pointer;
}

.edw-cluster-marker {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background-color: #FFD700;
border-radius: 100%;
font-size: 14px;
font-weight: 420;
color: black;
border: 1px solid white;
}

.view-mapbox {
position: relative;
}

form.exposed-mapbox-filters {
display: none;
position: absolute;
top: 0;
right: 0;
z-index: 2;
box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
background: #ffff;
padding: 2.5rem 3.125rem;
margin: 1.5rem;
}

form.exposed-mapbox-filters.form-visible {
display: block;
}

form .close-button {
position: absolute;
top: 0;
right: 10px;
cursor: pointer;
background-color: transparent;
border: none;
padding: 0;
font-size: 32px;
margin-right: 10px;
}

#toggleFiltersForm {
top: 0;
position: absolute;
z-index: 1;
right: 0;
margin: 1rem;
border: none;
background: #ffff;
border-radius: 2px;
display: none;
padding-left: 8px;
padding-right: 8px;
}

#toggleFiltersForm.button-visible {
display: block;
}
8 changes: 8 additions & 0 deletions modules/edw_maps/edw_maps.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: EDW Maps
description: This module provides Mapbox integration with views for custom and UN tiles.
package: Eau de Web
type: module
core_version_requirement: ^9 || ^10
dependencies:
- drupal:views
- drupal:geofield
15 changes: 15 additions & 0 deletions modules/edw_maps/edw_maps.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/**
* @file
* EDW Maps module install and update hooks.
*/

/**
* Implements hook_install().
*/
function edw_maps_install() {
/** @var \Drupal\edw_maps\Services\EdwMapsDataService $edwMapsUtils */
$edwMapsUtils = \Drupal::service('edw_maps.utils');
$edwMapsUtils->unzipGeoJson();
}
Loading