Browse Source

fixes map

Hima 5 years ago
parent
commit
25939ec83d
2 changed files with 34 additions and 20 deletions
  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"
             [circleDraggable]="true"
             [editable]="true">
             [editable]="true">
         </agm-circle>
         </agm-circle>
-      
       </agm-map>
       </agm-map>
     </div>
     </div>
+    <div class="col-12">
+      <button class="btn btn-success" (click)="saveLocation()" style="float: right; margin: 20px 0;">حفظ الإحدثيات</button>
+    </div>
   </div>
   </div>
 </div>
 </div>

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

@@ -62,13 +62,6 @@ export class MapComponent implements OnInit {
 
 
   mapClicked($event: MouseEvent) {
   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].lat = $event.coords.lat;
     this.markers[0].lng = $event.coords.lng;
     this.markers[0].lng = $event.coords.lng;
     // this.markers.push({
     // this.markers.push({
@@ -77,28 +70,47 @@ export class MapComponent implements OnInit {
     //   draggable: true
     //   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) {
   markerDragEnd(m: marker, $event: MouseEvent) {
     console.log('dragEnd', m, $event);
     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.
   // just an interface for type safety.
   interface marker {
   interface marker {