2013-03-12 76 views
1

我使用jQuery的gmap3插件,并使用'get'来获取特定的标记,我得到正确的标记,因为我可以访问marker.data我定义为我初始化地图,但我如何得到标记的位置,让地图缩放回调函数gmap3标记getPosition()不工作

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

所以任何人有一个想法?

先感谢您的任何暗示

+0

随着gmap3测试,执行对象不具有的属性,而不是原谷歌地图的方法?尝试'marker.position'或类似的。 – 2013-03-12 11:54:49

回答

2

试试这个:

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

+0

是的,这工作很好,但我不能访问marker.data了它现在不确定,但无论我标记为解决方案 – 2013-03-12 12:11:13