Skip to content

Commit

Permalink
fixes for pr
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBirtch-aot committed Jun 28, 2024
1 parent 97f9c28 commit 75fd4dc
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 25 deletions.
1 change: 0 additions & 1 deletion app/frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<script src="../node_modules/@bcgov/smk/dist/smk.js"></script>

<head>
<meta charset="utf-8">
Expand Down
6 changes: 0 additions & 6 deletions components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"components"
],
"dependencies": {
"@bcgov/smk": "^1.2.1",
"@types/leaflet": "^1.9.12",
"@types/leaflet-draw": "^1.0.11",
"autocompleter": "^7.0.1",
Expand Down
12 changes: 1 addition & 11 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@ export default class Component extends (FieldComponent as any) {
}

render() {
console.log('Rendering component');
return super.render(
`<div id="map-${this.componentID}" style="height:400px; z-index:1;"></div>`
);
}

attach(element) {
console.log('Attaching component to element');
const superAttach = super.attach(element);
this.loadMap();
return superAttach;
}

loadMap() {
console.log('Loading map');
const mapContainer = document.getElementById(`map-${this.componentID}`);
const form = document.getElementsByClassName('formio');
let drawOptions = {
Expand Down Expand Up @@ -83,8 +80,7 @@ export default class Component extends (FieldComponent as any) {
onDrawnItemsChange: this.saveDrawnItems.bind(this),
});

console.log('Current data value:', this.dataValue);
console.log('GetValue result:', this.getValue());


// Load existing data if available
if (this.dataValue) {
Expand All @@ -93,9 +89,7 @@ export default class Component extends (FieldComponent as any) {
}

saveDrawnItems(drawnItems: L.Layer[]) {
console.log('Saving drawn items:', drawnItems);
const value = drawnItems.map((layer: any) => {
console.log('Processing layer:', layer);
if (layer instanceof L.Marker) {
return {
type: 'marker',
Expand Down Expand Up @@ -125,19 +119,16 @@ export default class Component extends (FieldComponent as any) {
}
});

console.log('Converted value:', value);

// Convert to JSON string
const jsonValue =
this.component.numPoints === 1
? JSON.stringify(value[0])
: JSON.stringify(value);
console.log('JSON value to set:', jsonValue);
this.setValue(jsonValue);
}

setValue(value) {
console.log('Setting value:', value);
super.setValue(value);

// Additional logic to render the saved data on the map if necessary
Expand All @@ -152,7 +143,6 @@ export default class Component extends (FieldComponent as any) {
}

getValue() {
console.log('Getting value:', this.dataValue);
return this.dataValue;
}
}
6 changes: 0 additions & 6 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class MapService {
drawnItems: L.FeatureGroup;

constructor(options: MapServiceOptions) {
console.log('Initializing MapService with options:', options);
this.options = options;
if (options.mapContainer) {
const { map, drawnItems } = this.initializeMap(options);
Expand All @@ -36,7 +35,6 @@ class MapService {

// Event listener for drawn objects
map.on('draw:created', (e: any) => {
console.log('Drawing created:', e);
let layer = e.layer;
if (drawnItems.getLayers().length === options.numPoints) {
L.popup()
Expand All @@ -53,7 +51,6 @@ class MapService {
}

initializeMap(options: MapServiceOptions) {
console.log('Initializing map with options:', options);
let { mapContainer, center, drawOptions, form, defaultZoom } = options;
if (drawOptions.rectangle) {
drawOptions.rectangle.showArea = false;
Expand Down Expand Up @@ -89,7 +86,6 @@ class MapService {
}

bindPopupToLayer(layer: L.Layer) {
console.log('Binding popup to layer:', layer);
if (layer instanceof L.Marker) {
layer
.bindPopup(
Expand Down Expand Up @@ -120,7 +116,6 @@ class MapService {
}

loadDrawnItems(items: any) {
console.log('Loading drawn items:', items);
const { drawnItems } = this;

// Ensure drawnItems is defined before attempting to clear layers
Expand All @@ -137,7 +132,6 @@ class MapService {
}

items.forEach((item) => {
console.log('Processing item:', item);
let layer;
if (item.type === 'marker') {
layer = L.marker(item.latlng);
Expand Down

0 comments on commit 75fd4dc

Please sign in to comment.