agm-polygon not working properly with *ngFor, InvalidValueError: not an Array
See original GitHub issueIssue description Hi guys, I have a little problem with moving paths into a separated model. Let’s say I have a collection of restaurant. Each restaurant has a collection of delivery zones, each delivery zone has separated paths.
After changing [paths]="paths"
into [paths]="zone.paths"
I get
InvalidValueError: not an Array
My code is pretty simple:
<agm-map [latitude]="restaurant.latitude" [longitude]="restaurant.longitude">
<agm-marker [latitude]="restaurant.latitude" [longitude]="restaurant.longitude"></agm-marker>
<agm-polygon *ngFor="let zone of restaurant.delivery_zones" [fillColor]="red"
[fillOpacity]="0.5" [paths]="zone.paths"
[strokeColor]="blue" [strokeOpacity]="0.6" [strokeWeight]="2"
[visible]="true" [zIndex]="1"></agm-polygon>
</agm-map>
DeliveryZone model:
...
public paths = [
{lat: 25.774, lng: -80.190},
{lat: 18.466, lng: -66.118},
{lat: 32.321, lng: -64.757}
];
...
I’m not an expert in Angular.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:16
Top Results From Across the Web
agm-polygon not working properly with *ngFor ... - GitHub
Issue description Hi guys, I have a little problem with moving paths into a separated model. Let's say I have a collection of...
Read more >Developers - agm-polygon not working properly with *ngFor ...
agm-polygon not working properly with *ngFor, InvalidValueError: not an Array ... Hi guys, I have a little problem with moving paths into a ......
Read more >Uncaught InvalidValueError: not an Array - Stack Overflow
You need to construct the array first, and then use it when you create the polygon. In your code, you create a new...
Read more >SebastianM/angular2-google-maps - Gitter
Hallo Gays i have a problem with agm. I have implement agm in my project set latitude and longitude and it will not...
Read more >How to use ngfor to make a dropdown in Angular from an array
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tolvaly heres what the html snippet looks like for my map:
where ‘paths’ or ‘this.paths’ is produced by this function:
In which, I utilize ‘this._loader.load()’ where ‘this._loader’ is ‘MapsAPILoader’, defined in my constructor.
Later, for more detailed lines, I did the following to gain full access to the google maps api:
make sure to have ‘declare var google: any;’ at the top, along side your imports or you won’t be able to use the google objects like google.maps.Marker, etc.
Hope this helps!
I faced the same issue but was fixed after I mapped my data format from
Array<LatLngLiteral>
toArray<Array<LatLngLiteral>>
Working format
Seems like the
Array<LatLng | LatLngLiteral>
format is not working.package.json