Spaces:
Runtime error
Runtime error
Create index.html
Browse files- index.html +112 -0
index.html
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
```html
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html>
|
4 |
+
<head>
|
5 |
+
<title>Tree Counter</title>
|
6 |
+
<style>
|
7 |
+
body {
|
8 |
+
font-family: Arial, sans-serif;
|
9 |
+
}
|
10 |
+
.container {
|
11 |
+
width: 80%;
|
12 |
+
margin: 40px auto;
|
13 |
+
text-align: center;
|
14 |
+
}
|
15 |
+
.button {
|
16 |
+
background-color: #4CAF50;
|
17 |
+
color: #fff;
|
18 |
+
padding: 10px 20px;
|
19 |
+
border: none;
|
20 |
+
border-radius: 5px;
|
21 |
+
cursor: pointer;
|
22 |
+
}
|
23 |
+
.button:hover {
|
24 |
+
background-color: #3e8e41;
|
25 |
+
}
|
26 |
+
#google-earth-map {
|
27 |
+
height: 500px;
|
28 |
+
width: 100%;
|
29 |
+
border: 1px solid #ccc;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
+
</head>
|
33 |
+
<body>
|
34 |
+
<div class="container">
|
35 |
+
<h1>Tree Counter</h1>
|
36 |
+
<button class="button" id="upload-button">Upload Image</button>
|
37 |
+
<button class="button" id="crop-button" style="display: none;">Crop Image</button>
|
38 |
+
<div id="result"></div>
|
39 |
+
<div id="google-earth-map"></div>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<script>
|
43 |
+
const uploadButton = document.getElementById('upload-button');
|
44 |
+
const cropButton = document.getElementById('crop-button');
|
45 |
+
const resultDiv = document.getElementById('result');
|
46 |
+
const googleEarthMap = document.getElementById('google-earth-map');
|
47 |
+
|
48 |
+
uploadButton.addEventListener('click', (e) => {
|
49 |
+
e.preventDefault();
|
50 |
+
const input = document.createElement('input');
|
51 |
+
input.type = 'file';
|
52 |
+
input.accept = 'image/*';
|
53 |
+
input.onchange = (e) => {
|
54 |
+
const image = e.target.files[0];
|
55 |
+
const formData = new FormData();
|
56 |
+
formData.append('image', image);
|
57 |
+
fetch('/upload_image', {
|
58 |
+
method: 'POST',
|
59 |
+
body: formData
|
60 |
+
})
|
61 |
+
.then((response) => response.json())
|
62 |
+
.then((data) => {
|
63 |
+
if (data.message.includes('too large')) {
|
64 |
+
cropButton.style.display = 'inline-block';
|
65 |
+
} else {
|
66 |
+
resultDiv.innerText = data.message;
|
67 |
+
}
|
68 |
+
});
|
69 |
+
};
|
70 |
+
input.click();
|
71 |
+
});
|
72 |
+
|
73 |
+
cropButton.addEventListener('click', (e) => {
|
74 |
+
e.preventDefault();
|
75 |
+
const input = document.createElement('input');
|
76 |
+
input.type = 'file';
|
77 |
+
input.accept = 'image/*';
|
78 |
+
input.onchange = (e) => {
|
79 |
+
const image = e.target.files[0];
|
80 |
+
const formData = new FormData();
|
81 |
+
formData.append('image', image);
|
82 |
+
fetch('/crop_image', {
|
83 |
+
method: 'POST',
|
84 |
+
body: formData
|
85 |
+
})
|
86 |
+
.then((response) => response.json())
|
87 |
+
.then((data) => {
|
88 |
+
resultDiv.innerText = data.message;
|
89 |
+
});
|
90 |
+
};
|
91 |
+
input.click();
|
92 |
+
});
|
93 |
+
|
94 |
+
// Initialize Google Earth map
|
95 |
+
const googleEarthOptions = {
|
96 |
+
zoom: 4,
|
97 |
+
center: { lat: 37.7749, lng: -122.4194 },
|
98 |
+
mapTypeId: 'satellite'
|
99 |
+
};
|
100 |
+
const googleEarthMapInstance = new google.maps.Map(googleEarthMap, googleEarthOptions);
|
101 |
+
|
102 |
+
// Add event listener to Google Earth map
|
103 |
+
googleEarthMapInstance.addListener('click', (e) => {
|
104 |
+
const lat = e.latLng.lat();
|
105 |
+
const lng = e.latLng.lng();
|
106 |
+
console.log(`Clicked at (${lat}, ${lng})`);
|
107 |
+
});
|
108 |
+
</script>
|
109 |
+
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
|
110 |
+
</body>
|
111 |
+
</html>
|
112 |
+
```
|