1

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 ;-)

WalkerNuss
  • 435
  • 5
  • 9
  • 1
    Possible duplicate of [Getting Lat/Lng from Google marker](http://stackoverflow.com/questions/5290336/getting-lat-lng-from-google-marker) – Andreas Oct 12 '15 at 10:18
  • I dont want retrieve new coordinates but how to point specific element ^^ – WalkerNuss Oct 12 '15 at 10:25
  • 1
    `getPosition` will work on marker object and in your code `var markerPrt = $('marker_'+relationId);` looks like you are picking element of marker which will not work. Where did you plot the marker on map in code, try making it global and then user `getPosition` – Anand G Oct 12 '15 at 10:59
  • What is `markerPrt`? Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that demonstrates the issue. – geocodezip Oct 12 '15 at 13:06
  • You are right, I will prepare a JSFIddle, sorry – WalkerNuss Oct 12 '15 at 14:17

2 Answers2

5

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.

Blady214
  • 729
  • 6
  • 19
0

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.

Blady214
  • 729
  • 6
  • 19