Hima 5 år sedan
förälder
incheckning
25939ec83d
2 ändrade filer med 34 tillägg och 20 borttagningar
  1. 3 1
      src/app/dashboard/map/map.component.html
  2. 31 19
      src/app/dashboard/map/map.component.ts

+ 3 - 1
src/app/dashboard/map/map.component.html

@@ -37,8 +37,10 @@
             [circleDraggable]="true"
             [editable]="true">
         </agm-circle>
-      
       </agm-map>
     </div>
+    <div class="col-12">
+      <button class="btn btn-success" (click)="saveLocation()" style="float: right; margin: 20px 0;">حفظ الإحدثيات</button>
+    </div>
   </div>
 </div>

+ 31 - 19
src/app/dashboard/map/map.component.ts

@@ -62,13 +62,6 @@ export class MapComponent implements OnInit {
 
   mapClicked($event: MouseEvent) {
     
-    const dataMap={
-      latitude: $event.coords.lat,
-      longitude: $event.coords.lng,
-      id: 1
-    }
-
-    console.log('responce map', dataMap);
     this.markers[0].lat = $event.coords.lat;
     this.markers[0].lng = $event.coords.lng;
     // this.markers.push({
@@ -77,28 +70,47 @@ export class MapComponent implements OnInit {
     //   draggable: true
     // });
 
-    this.http.post(this.authSer.pathApi + '/edit_reach_map', dataMap).subscribe(
-      (responce) => {
-        console.log(responce);
-        this.toastr.success('تم حفظ الموقع');
-      },
-      (error) => {
-        console.log(error);
-        this.toastr.error('خطأ في الموقع إنتظر قليلاً');
-      }
-    );
-
-    console.log(this.markers);
+   
   }
 
   markerDragEnd(m: marker, $event: MouseEvent) {
     console.log('dragEnd', m, $event);
+    this.markers[0].lat = $event.coords.lat;
+    this.markers[0].lng = $event.coords.lng;
+    console.log('wwwwwwwwwwwwwwwwwwwwww' , this.markers);
   }
 
+
+saveLocation() {
+  console.log(this.markers);
   
+  const dataMap={
+    latitude: this.markers[0].lat,
+    longitude: this.markers[0].lng,
+    id: 1
+  }
+
+  console.log('responce map', dataMap);
+
+  this.http.post(this.authSer.pathApi + '/edit_reach_map', dataMap).subscribe(
+    (responce) => {
+      console.log(responce);
+      this.toastr.success('تم حفظ الموقع');
+    },
+    (error) => {
+      console.log(error);
+      this.toastr.error('خطأ في الموقع إنتظر قليلاً');
+    }
+  );
 
 }
 
+  
+
+}
+
+
+
 
   // just an interface for type safety.
   interface marker {