2012-02-23 89 views
1
// Update the radius when the user makes a selection. 
google.maps.event.addDomListener(document.getElementById('radius'), 
    'change', function() { 
     var meters = parseInt(this.value, 10); 
     layer.setOptions({ 
     query: { 
      select: locationColumn, 
      from: tableId, 
      where: 'ST_INTERSECTS(Latitude, ' + 
       'CIRCLE(LATLNG(53.337638, -6.266971), ' + meters + '))' 
      } 
     }); 
     circle.setRadius(meters); 
     //alert(position); 
     //circle.setCenter(new google.maps.LatLng(position)); 
}); 

我想改變(53.337638,-6.266971)是一個varible「位置」,位置與(X,Y)相同的值類型,但它不與 哪裏工作:「ST_INTERSECTS(緯度,'+ 'CIRCLE(LATLNG('+ position +'),'+ meters +'))' 如何修改代碼?如何更改JavaScript代碼?

回答

0

一個簡短的解決方案是:

var position = [53.337638, -6.266971]; 
// irrelenant query code skipped 
... + 'CIRCLE(LATLNG('+position[0]+','+position[1]+'), ' ... 

更長的(但更好的語義)的解決辦法是定義一個對象有兩個屬性, 然後重載它的toString()方法。

0

你可以單獨指定的position兩個屬性,就像這樣:

LATLNG(position.x, position.y)