Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBirtch-aot committed Feb 24, 2025
1 parent 3c66835 commit 42a4dfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
5 changes: 0 additions & 5 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default class Component extends (FieldComponent as any) {
}

loadMap() {
console.log('Map Loading');
const mapContainer = document.getElementById(`map-${this.componentID}`);
const form = document.getElementsByClassName('formio');

Expand Down Expand Up @@ -123,7 +122,6 @@ export default class Component extends (FieldComponent as any) {
// Load existing data if available
if (this.dataValue && this.dataValue.features) {
try {
console.log('Loading Drawn Items' + this.dataValue.features);
this.mapService.loadDrawnItems(this.dataValue.features);
} catch (error) {
console.error('Failed to parse dataValue:', error);
Expand Down Expand Up @@ -161,14 +159,11 @@ export default class Component extends (FieldComponent as any) {
};
}
});
console.log('Saving Drawn Items' + features);
this.setValue({ features });
}

setValue(value) {
super.setValue(value);
console.log('Setting Value' + value);
console.log('DrawnItems' + this.mapService.drawnItems?.getLayers());
// Additional logic to render the saved data on the map if necessary
if (this.mapService && value && value.features) {
try {
Expand Down
45 changes: 12 additions & 33 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,7 @@ class MapService {
}
return { map, drawnItems, drawControl };
}
disableDeleteMode() {
if (this.drawControl && this.drawControl._toolbars?.edit) {
const editToolbar = this.drawControl._toolbars.edit;
const deleteHandler = editToolbar._modes.remove.handler;
if (deleteHandler.enabled()) {
deleteHandler.disable();
}
/*if (this.drawControl?._toolbars?.edit) {
console.log('Disabling edit/delete mode...', this.drawControl._toolbars, 'edit', this.drawControl._toolbars.edit);
// this.drawControl._toolbars.edit.disable();
}*/
}
}

bindPopupToLayer(layer) {
if (layer instanceof L.Marker) {
layer
Expand Down Expand Up @@ -270,17 +258,14 @@ class MapService {
}

loadDrawnItems(items) {
console.log('Loading Drawn Items');
const { drawnItems } = this;
console.log(drawnItems.getLayers());
if (!drawnItems) {
console.error('drawnItems is undefined');
return;
}
if (!Array.isArray(items)) {
items = [items];
}
console.log(items);
//items are stored in a naive fashion for ease
//of readability for CHEFS reviewers
let features = this.arrayToFeatureGroup(items);
Expand All @@ -303,6 +288,17 @@ class MapService {
return false;
}

isDefaultFeature(feature): boolean {
if (
this.defaultFeatures.getLayers() === 0 ||
this.defaultFeatures === null
) {
return false;
}

return this.isFeatureInArray(feature, this.defaultFeatures.getLayers());
}

isFeatureInArray(feature, array): boolean {
if (feature === null) return false;
if (array.length === 0 || array === null) {
Expand All @@ -314,7 +310,6 @@ class MapService {
}); // filter out the types that don't match
if (sameTypes.length === 0) {
//no matching types, no match
console.log('No matching type');
return false;
}
return sameTypes.some((f) => {
Expand Down Expand Up @@ -360,16 +355,6 @@ class MapService {
return features;
}

isDefaultFeature(feature): boolean {
if (
this.defaultFeatures.getLayers() === 0 ||
this.defaultFeatures === null
) {
return false;
}

return this.isFeatureInArray(feature, this.defaultFeatures.getLayers());
}
getFeatureType(feature) {
if (feature instanceof L.Marker) {
return 'marker';
Expand All @@ -384,9 +369,6 @@ class MapService {
}
}
coordinatesEqual(c1, c2) {
c1.lat === c2.lat && c1.lng === c2.lng
? console.log('Coordinates Match')
: console.log("Coordinates Don't match");
return c1.lat === c2.lat && c1.lng === c2.lng;
}
polyEqual(c1, c2) {
Expand All @@ -398,16 +380,13 @@ class MapService {
}
if (c1.length !== c2.length) {
// different number of vertices, no match
console.log('Different Length of polygons');
return false;
} else {
for (let i = 0; i < c1.length; i++) {
if (!this.coordinatesEqual(c1[i], c2[i])) {
return false; // if there's no match in one of the points, it's a new feature
}
console.log(`${i}th point matches`);
}
console.log('Polygons Are Equal');
return true;
}
}
Expand Down

0 comments on commit 42a4dfa

Please sign in to comment.