cannot push markers on map although have latitude and longitude points ?

5 views
Skip to first unread message

ahmed elbarbary

unread,
Dec 31, 2019, 8:25:11 PM12/31/19
to Angular and AngularJS discussion
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
 
longitude for more points 
 
but these points not exists on map . 
 
step 1 : on html component
<agm-map 
 
 
[latitude]="lat"  
 
[longitude]="lng"  
 
[zoom]="zoom"  
 
[disableDefaultUI]="false"  
 
[zoomControl]="false">  
 
 
<agm-marker  
     
*ngFor="let m of markers;"  
     
[latitude]="m.lat"  
     
[longitude]="m.long"  
     
>  
     
 
</agm-marker>  
   
 
 
</
agm-map>  



 step2 :service.ts

getLocationData(ids: Array<number>) {   
 
        let observableBatch
= [];  
     
      ids
.forEach((id) => {  
     
            observableBatch
.push(  
                 
this.http.get('http://192.168.7.45:9200/location/_doc/'+id)  
                         
.map(res => res ));  
       
});  
     
       
return Observable.forkJoin(observableBatch);  
   
}  

 
step3 :on component.ts


export class ManagelocationsComponent implements OnInit, AfterViewInit {
markers
=[];


this.partDetailsService.getLocationData(locationArr).subscribe(res => {  
          res
.forEach((item, index) => {  
       
            let dataLocation
= res[index]['_source']['GPS1'];  
           
var loc = dataLocation.split(',');  
           
this.markers.push(  
              parseFloat
(loc[0].trim()),  
              parseFloat
(loc[1].trim())  
           
})  
console
.log("marker values is" + this.markers);  


Result points for latitude and longitude from browser console :
 
marker values is
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 .

Reply all
Reply to author
Forward
0 new messages