0

このコードでメソッド getPosition を使用したい:

alert("Tap location in this map");
google.maps.event.addListener(map, 'click', function(event) {
    mArray[count] = new google.maps.Marker({
        position: event.latLng,
        map: map
    });
});
mArray[count].getPosition();

しかし、getPosition を呼び出すことはできません。

Uncaught TypeError: Cannot call method 'getPosition' of undefined

countグローバル変数です。

var count=0;
var mArray = [];

誰かがそれを説明できますか?

4

1 に答える 1