allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 517 forks source link

using shape gives error : InvalidValueError: not an Array #863

Closed VaishaliRavindran closed 6 years ago

VaishaliRavindran commented 6 years ago

Current behavior I am having a map and set of users. If no user is selected I am displaying last recorded positions of all the users. If 1 user is selected, I am using shape tag to display his movements. It works while a user is selected. But, If user is removed from selection box, I am getting error . InvalidValueError: not an Array. But, the map is displayed correctly. I am using ng-if conditions in shape tag and marker tag. If I remove shape tag , I am not getting errors.

Expected/desired behavior

No errors

Code Implementation

<ng-map center="12.97, 77.58" zoom="8">
    <marker ng-if="!selected.runner" ng-repeat="pos in markersArray track by $index" position="  {{pos.lat}}, {{pos.lng}}" title="{{pos.title}}" icon="/assets/bike.png"></marker>
    <marker ng-if="selected.runner && markersArray[0]" position="{{markersArray[0].lat}}, {{markersArray[0].lng}}" title="{{markersArray[0].title}}" icon="/assets/bike.png"></marker>
    <shape ng-if="selected.runner && path.length >0" name="polyline" path="{{path}}" geodesic="true" stroke-color="#5B2C6F" stroke-opacity="1.0" stroke-weight="2"></shape>
 </ng-map>
allenhwkim commented 6 years ago

Please take a look at this, https://ngmap.github.io/#/!shape_with_ng_repeat.html. and if still not resolved create a plunker with "Run in plunker" button" to reproduce your error.

VaishaliRavindran commented 6 years ago

Inserting dummy values in 'path' array like path=[[0,0]], solved my problem. In my code, before inserting actual values in array, I am clearing it. So, these dummy values wont cause problem.

allenhwkim commented 6 years ago

please close this if resolved