gmap3 Маркер getPosition() не работает

Я использую плагин gmap3 для jquery и использую get для получения определенного маркера, я получаю правильный маркер, так как могу получить доступ marker.data я определил, как я инициализирую карту, но как я могу получить положение маркера, чтобы позволить карте приблизиться к этой позиции внутри функции обратного вызова

$('#map').gmap3({
    get: {
        name:"marker",
        tag:"${i}",
        full:true,
        callback: function(marker){
            var center = marker.getPosition();
            $('#getdistance').gmap3({
                map:{
                    center:center,
                    options:{
                        zoom:17,
                        mapTypeControl: true,
                        mapTypeControlOptions: {
                            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                        },
                        navigationControl: true,
                        scrollwheel: true,
                        streetViewControl: true
                    }
                }
            });    
        }
    }
});

Попытка так выдает ошибку:

 marker.getPosition is not a function

так у кого есть идеи?

заранее спасибо за любую подсказку

1 ответ

Решение

Попробуй это:

$('#map').gmap3({
    marker: {// change get to marker
        name:"marker",
        tag:"${i}",
        full:true,
        callback: function(marker){
            var center = marker.getPosition();
            $('#getdistance').gmap3({
                map:{
                    center:center,
                    options:{
                        zoom:17,
                        mapTypeControl: true,
                        mapTypeControlOptions: {
                            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                        },
                        navigationControl: true,
                        scrollwheel: true,
                        streetViewControl: true
                    }
                }
            });    
        }
    }
});

Протестируйте здесь http://gmap3.net/en/catalog/14-services/getaddress-49

Другие вопросы по тегам