Muzanfer commited on
Commit
a0eae8f
·
verified ·
1 Parent(s): 0d7bb62

dostum bana güzergah düzenleme ekranı hazırlamanı istiyorum. güzergah başlığı ve haritada noktalar seçebileceğim bir sayfa ekle ben butona basınca o sayfaya gidebileyim.

Browse files
Files changed (3) hide show
  1. components/sidebar.js +2 -2
  2. routes.html +185 -0
  3. style.css +5 -0
components/sidebar.js CHANGED
@@ -55,11 +55,11 @@ class CustomSidebar extends HTMLElement {
55
  <i data-feather="users" class="w-4 h-4 mr-3"></i>
56
  Drivers
57
  </a>
58
- <a href="#" class="nav-item flex items-center px-4 py-2 text-sm font-medium text-gray-900 rounded-md">
59
  <i data-feather="map" class="w-4 h-4 mr-3"></i>
60
  Routes
61
  </a>
62
- </div>
63
 
64
  <div class="space-y-2">
65
  <h3 class="px-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">Monitoring</h3>
 
55
  <i data-feather="users" class="w-4 h-4 mr-3"></i>
56
  Drivers
57
  </a>
58
+ <a href="routes.html" class="nav-item flex items-center px-4 py-2 text-sm font-medium text-gray-900 rounded-md">
59
  <i data-feather="map" class="w-4 h-4 mr-3"></i>
60
  Routes
61
  </a>
62
+ </div>
63
 
64
  <div class="space-y-2">
65
  <h3 class="px-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">Monitoring</h3>
routes.html ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Route Editor | Dolmuş Tracker Admin</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
11
+ </head>
12
+ <body class="bg-gray-50">
13
+ <custom-navbar></custom-navbar>
14
+ <div class="flex">
15
+ <custom-sidebar></custom-sidebar>
16
+ <main class="flex-1 p-8">
17
+ <div class="flex items-center justify-between mb-6">
18
+ <h1 class="text-2xl font-bold text-gray-800">Route Editor</h1>
19
+ <button id="save-route" class="bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-md flex items-center">
20
+ <i data-feather="save" class="w-4 h-4 mr-2"></i>
21
+ Save Route
22
+ </button>
23
+ </div>
24
+
25
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
26
+ <div class="lg:col-span-2 bg-white rounded-lg shadow p-6">
27
+ <div id="map" class="h-[600px] rounded-lg"></div>
28
+ </div>
29
+
30
+ <div class="bg-white rounded-lg shadow p-6">
31
+ <div class="mb-6">
32
+ <label for="route-name" class="block text-sm font-medium text-gray-700 mb-1">Route Name</label>
33
+ <input type="text" id="route-name" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary-500">
34
+ </div>
35
+
36
+ <div class="mb-6">
37
+ <label class="block text-sm font-medium text-gray-700 mb-1">Route Stops</label>
38
+ <div id="route-stops" class="space-y-2 max-h-96 overflow-y-auto p-2 border border-gray-200 rounded-md">
39
+ <p class="text-gray-500 text-sm">Click on the map to add stops</p>
40
+ </div>
41
+ </div>
42
+
43
+ <div class="flex space-x-2">
44
+ <button id="clear-route" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md flex items-center justify-center">
45
+ <i data-feather="trash-2" class="w-4 h-4 mr-2"></i>
46
+ Clear
47
+ </button>
48
+ <button id="reverse-route" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md flex items-center justify-center">
49
+ <i data-feather="repeat" class="w-4 h-4 mr-2"></i>
50
+ Reverse
51
+ </button>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </main>
56
+ </div>
57
+
58
+ <script src="components/navbar.js"></script>
59
+ <script src="components/sidebar.js"></script>
60
+ <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
61
+ <script>
62
+ document.addEventListener('DOMContentLoaded', function() {
63
+ feather.replace();
64
+
65
+ // Initialize map
66
+ const map = L.map('map').setView([41.0082, 28.9784], 12); // Istanbul coordinates
67
+ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
68
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
69
+ }).addTo(map);
70
+
71
+ const routeStops = [];
72
+ const markers = [];
73
+ const polyline = L.polyline([], {color: '#3B82F6'}).addTo(map);
74
+
75
+ // Map click handler
76
+ map.on('click', function(e) {
77
+ const stopNumber = routeStops.length + 1;
78
+ const marker = L.marker(e.latlng, {
79
+ draggable: true,
80
+ icon: L.divIcon({
81
+ className: 'custom-marker',
82
+ html: `<div class="bg-primary-600 text-white rounded-full w-8 h-8 flex items-center justify-center font-bold">${stopNumber}</div>`
83
+ })
84
+ }).addTo(map);
85
+
86
+ marker.on('dragend', function() {
87
+ updateRoute();
88
+ });
89
+
90
+ markers.push(marker);
91
+ routeStops.push({
92
+ lat: e.latlng.lat,
93
+ lng: e.latlng.lng,
94
+ name: `Stop ${stopNumber}`
95
+ });
96
+
97
+ updateRoute();
98
+ updateStopList();
99
+ });
100
+
101
+ function updateRoute() {
102
+ const latlngs = markers.map(marker => marker.getLatLng());
103
+ polyline.setLatLngs(latlngs);
104
+ map.fitBounds(polyline.getBounds());
105
+ }
106
+
107
+ function updateStopList() {
108
+ const stopsContainer = document.getElementById('route-stops');
109
+ stopsContainer.innerHTML = '';
110
+
111
+ if (routeStops.length === 0) {
112
+ stopsContainer.innerHTML = '<p class="text-gray-500 text-sm">Click on the map to add stops</p>';
113
+ return;
114
+ }
115
+
116
+ routeStops.forEach((stop, index) => {
117
+ const stopElement = document.createElement('div');
118
+ stopElement.className = 'flex items-center justify-between p-2 bg-gray-50 rounded';
119
+ stopElement.innerHTML = `
120
+ <div class="flex items-center">
121
+ <span class="bg-primary-600 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs font-bold mr-2">${index + 1}</span>
122
+ <span>${stop.name}</span>
123
+ </div>
124
+ <button class="text-red-500 hover:text-red-700" data-index="${index}">
125
+ <i data-feather="x" class="w-4 h-4"></i>
126
+ </button>
127
+ `;
128
+ stopsContainer.appendChild(stopElement);
129
+ });
130
+
131
+ // Add event listeners to delete buttons
132
+ document.querySelectorAll('#route-stops button').forEach(button => {
133
+ button.addEventListener('click', function() {
134
+ const index = parseInt(this.getAttribute('data-index'));
135
+ routeStops.splice(index, 1);
136
+ map.removeLayer(markers[index]);
137
+ markers.splice(index, 1);
138
+ updateRoute();
139
+ updateStopList();
140
+ });
141
+ });
142
+
143
+ feather.replace();
144
+ }
145
+
146
+ // Button handlers
147
+ document.getElementById('clear-route').addEventListener('click', function() {
148
+ routeStops.length = 0;
149
+ markers.forEach(marker => map.removeLayer(marker));
150
+ markers.length = 0;
151
+ polyline.setLatLngs([]);
152
+ updateStopList();
153
+ });
154
+
155
+ document.getElementById('reverse-route').addEventListener('click', function() {
156
+ routeStops.reverse();
157
+ markers.reverse();
158
+ updateRoute();
159
+ updateStopList();
160
+ });
161
+
162
+ document.getElementById('save-route').addEventListener('click', function() {
163
+ const routeName = document.getElementById('route-name').value;
164
+ if (!routeName) {
165
+ alert('Please enter a route name');
166
+ return;
167
+ }
168
+
169
+ if (routeStops.length < 2) {
170
+ alert('Please add at least 2 stops to create a route');
171
+ return;
172
+ }
173
+
174
+ // Here you would typically send data to your backend
175
+ console.log('Saving route:', {
176
+ name: routeName,
177
+ stops: routeStops
178
+ });
179
+
180
+ alert('Route saved successfully!');
181
+ });
182
+ });
183
+ </script>
184
+ </body>
185
+ </html>
style.css CHANGED
@@ -32,6 +32,11 @@ body {
32
  from { opacity: 0; }
33
  to { opacity: 1; }
34
  }
 
 
 
 
 
35
 
36
  /* Badge styles */
37
  .badge {
 
32
  from { opacity: 0; }
33
  to { opacity: 1; }
34
  }
35
+ /* Custom marker styles */
36
+ .custom-marker {
37
+ background: transparent;
38
+ border: none;
39
+ }
40
 
41
  /* Badge styles */
42
  .badge {