1
votes

i´m using gmap3 plugin for jquery and use 'get' to get a specific marker, i do get the right marker, as i can access marker.data i defined as i init the map, but how do i get the position of the marker to let the map zoom to this position inside the callback function

$('#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
                    }
                }
            });    
        }
    }
});

trying so throws error :

 marker.getPosition is not a function

so anyone has an idea ?

thanks in advance for any hint

1
With gmap3, do objects not have properties as opposed to raw Google Maps' methods? Try marker.position or similar.Beetroot-Beetroot

1 Answers

2
votes

Try this:

$('#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
                    }
                }
            });    
        }
    }
});

Test here http://gmap3.net/en/catalog/14-services/getaddress-49