无法读取未定义的属性'lng'

时间:2018-01-22 11:27:07

标签: angularjs google-maps ng-map

我正在使用ng-map.min.js

在谷歌地图中使用客户标记

我正在更改自定义标记的位置,但它显示以下错误:

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 ...?

1 个答案:

答案 0 :(得分:0)

以下函数在代码中返回什么内容?

p.position = [0,0]

您在视图中传递的模型(p.position)应该是一维数组:

{{1}}

第一个索引是'lat',第二个索引是'lng。