angularjsgoogle-mapsng-map

Cannot read property 'lng' of undefined


I am using customer marker in google maps using ng-map.min.js

I am change the position of the custom marker, but it is showing the following error :

Uncaught TypeError: Cannot read property 'lng' of undefined
    at a.setPosition (ng-map.min.js:25)
    at a.draw (ng-map.min.js:25)
    at a.Mz (overlay.js:1)
    at js?key=xxx&callback=lazyLoadCallback:138

The code i write for custom marker is :

in html file :
==============


<custom-marker ng-repeat="p in page.watchpath track by $index" position="{{p.Location.position}}">
                <div>
                    <img src="{{p.ImagePath ? page.serviceBasePath + p.ImagePath.substr(2) : page.serviceBasePath + 'Images/avatar.jpg'}}" style="border-radius: 50%; height:40px;width:40px;" />
                </div>
            </custom-marker>

in js file :
============


page.watchpath[deviceindex] = { position: device.Location.position, ImagePath: imagePath };

But When i am using for marker tag it is not showing any error :


<marker ng-repeat="p in page.watchpath track by $index" position="{{p.position}}"></marker>

 When i am using for custom-marker tag it showing error message  

How to rectify this error ?

Please help me ...?

Solution

  • What does the following function returns in your code?

    device.Location.position
    

    The model which you pass in your view (p.position) should be a one dimension array:

    p.position = [0,0]
    

    The first index is 'lat' the second is 'lng.