WalkerNuss
WalkerNuss

Reputation: 465

Google Map v3 - getPosition is not a function

I try to point a marker on the map with the following call :

$('#sideBar').on('click','.rightCliker',function(e){
        e.preventDefault();
        var relationId      = $(this).attr('data-id');
        var markerPrt       = $('marker_'+relationId);
        map.setZoom(9);
        map.setCenter(markerPrt.getPosition());
    });

But I get the following error:

Uncaught TypeError: markerPrt.getPosition is not a function

What have I done wrong? Thanks ;-)

Upvotes: 1

Views: 6763

Answers (2)

Blady214
Blady214

Reputation: 739

You could try to assigin your marker to array position via HTML data attribute: http://www.w3schools.com/tags/att_global_data.asp where you can store any value e.g. array index of given marker or even its coords.

Upvotes: 0

Blady214
Blady214

Reputation: 739

I am not sure but check the type of your JS element. I suspect that it is a DOM object not a Marker object. Add to your function: console.log(markerPrt) and check in browser console what is the type of your object.

Upvotes: 5

Related Questions