ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 256.3k

cannot push markers on map although have latitude and longtu

Dec 31 2019 7:07 PM
 I using angular 7
 
google map already display without points pushed on it .
 
meaning all points not display on map although i have latitude and
 
longtude for more points 
 
but these points not exists on map . 
 
step 1 : on html component
  1. <agm-map   
  2.   [latitude]="lat"  
  3.   [longitude]="lng"  
  4.   [zoom]="zoom"  
  5.   [disableDefaultUI]="false"  
  6.   [zoomControl]="false">  
  7.   
  8.   <agm-marker   
  9.       *ngFor="let m of markers;"  
  10.       [latitude]="m.lat"  
  11.       [longitude]="m.long"  
  12.       >  
  13.       
  14.   </agm-marker>  
  15.     
  16.   
  17.   
  18. </agm-map>  
 step2 :service.ts
  1. getLocationData(ids: Array<number>) {    
  2.         let observableBatch = [];  
  3.       
  4.       ids.forEach((id) => {  
  5.       
  6.             observableBatch.push(  
  7.                   this.http.get('http://192.168.7.45:9200/location/_doc/'+id)  
  8.                           .map(res => res ));  
  9.         });  
  10.       
  11.         return Observable.forkJoin(observableBatch);  
  12.     }  
 
step3 :on component.ts
  1. export class ManagelocationsComponent implements OnInit, AfterViewInit {
    markers=[];

  2. this.partDetailsService.getLocationData(locationArr).subscribe(res => {  
  3.           res.forEach((item, index) => {  
  4.         
  5.             let dataLocation = res[index]['_source']['GPS1'];  
  6.             var loc = dataLocation.split(',');  
  7.             this.markers.push(  
  8.               parseFloat(loc[0].trim()),  
  9.               parseFloat(loc[1].trim())  
  10.            })  
  11. console.log("marker values is" + this.markers);  
Result points for latitude and longtude from browser
 
  1. marker values is
  2. 5.2951916,100.28825170000005,30.788892,120.632503,13.658933,100.634069,10.328074,123.983185,31.332119,120.723465,31.9195204,120.1029251,18.588375,99.033632,31.301726,120.673733,31.306624,121.616856,14.3091,121.033,22.783944,113.798342,14.173507,121.129545,29.9211,103.797,10.328071,123.98318500000005,2.679124,101.978932,34.593,133.495,43.6407309,-70.32520110000002,31.8406,120.482,1.37437,103.863366,15.4507,120.605,37.5127,126.786  
 google map not show points above why and how to solve it .