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

Fix - Homepage Interactive Map - Participatory Process Marker #37

Merged
Changes from all commits
Commits
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
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 @@ -44,6 +44,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 @@ -89,25 +90,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 @@ -282,7 +280,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 @@ -315,9 +313,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 @@ -349,5 +344,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);