Skip to content

Commit

Permalink
Fix - Homepage Interactive Map - Participatory Process Marker (#37)
Browse files Browse the repository at this point in the history
* Modifying calculation to fix the bug of the circle going straight out of her participatory_process on interactive map

* Trying to fix entirely the bug of the position of the processMarkers

* Trying to fix with a further investigation the map but doesn't work yet

* Fixing the movement of the participatory process marker

* Reverting useless changes
  • Loading branch information
AyakorK authored Jul 26, 2022
1 parent 8b99113 commit 063bd43
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions app/packs/src/decidim/homepage_interactive_map/interactive_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ L.DivIcon.SVGIcon.DecidimIcon = L.DivIcon.SVGIcon.extend({
const iconSize = 28;

const map = L.map('interactive_map');

// Add Proj4 configurations
proj4.defs("EPSG:3943", "+proj=lcc +lat_1=42.25 +lat_2=43.75 +lat_0=43 +lon_0=3 +x_0=1700000 +y_0=2200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");

Expand Down Expand Up @@ -87,25 +88,22 @@ L.DivIcon.SVGIcon.DecidimIcon = L.DivIcon.SVGIcon.extend({
}

function isCoordinates(value, length) {
return Array.isArray(value) && (value.length == length) && !!value.reduce((a,v) => (a && (a !== null)));
return Array.isArray(value) && (value.length === length) && !!value.reduce((a, v) => (a && (a !== null)));
}

function hasLocation(participatory_process) {
return (participatory_process.location !== undefined) && isCoordinates(participatory_process.location, 2);
}

function updateProcessMarkerPosition(marker, delta, zoom) {
let oldPoint = map.project(L.latLng(marker.origin), zoom);
let oldPoint = map.project(L.latLng(marker.origin), zoom);

let radius = ( delta / 2 ) + ( marker.getRadius() / 1.75 ) ;
let radius = ( delta / 2.5 ) + ( marker.getRadius() / 1.75 ) ;
let newPoint = L.point(
oldPoint.x + ( radius * Math.cos( Math.PI / 4 ) ),
oldPoint.y - ( radius * Math.sin( Math.PI / 4 ) )
oldPoint.x + ( radius * Math.cos( Math.PI / 4 ) ),
oldPoint.y - ( radius * Math.sin( Math.PI / 4 ) )
);

// TODO: setLatLng method can occur error
marker._latlng = map.unproject(newPoint, zoom);
//marker.setLatLng(map.unproject(newPoint, zoom));
}

function calculateIconSize() {
Expand Down Expand Up @@ -302,7 +300,7 @@ L.DivIcon.SVGIcon.DecidimIcon = L.DivIcon.SVGIcon.extend({
zoomOrigin = map.getZoom();


// Noww, all the element are actually projected on the map
// Now, all the element are actually projected on the map
allProcessesLayer.eachLayer((marker) => {

// Each participatory process should highlight its linked assemblies / zones
Expand Down Expand Up @@ -335,9 +333,6 @@ L.DivIcon.SVGIcon.DecidimIcon = L.DivIcon.SVGIcon.extend({
}
});

// Add markers to map
allProcessesLayer.addTo(map);


// Map zoom events
map.on('zoomstart', (e) => {
Expand Down Expand Up @@ -369,5 +364,7 @@ L.DivIcon.SVGIcon.DecidimIcon = L.DivIcon.SVGIcon.extend({
allProcessesLayer.refreshClusters();
$('#interactive_map .leaflet-process-pane').show();
});
// Add markers to map
allProcessesLayer.addTo(map);
});
})(window);

0 comments on commit 063bd43

Please sign in to comment.