2012-02-23 1 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)); 
}); 

I는 varible '위치'로 (-6.266971, 53.337638)를 변경하는 경우, 다음 위치 (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)