2014-05-12 189 views
-1

這是我使用的代碼的肉,我沒有得到錯誤,但我沒有看到矩形區域中的點。任何幫助,將不勝感激:Google Maps API繪製矩形

`enter code here`/** @this {google.maps.Rectangle} */ 
function showNewRect(event) { 
var ne = rectangle.getBounds().getNorthEast(); 
var sw = rectangle.getBounds().getSouthWest(); 
google.maps.event.addlistener(rectangle, "bounds_changed", function(){ 
    document.getElementById("map-selected").innerHTML=rectangle.getBounds(); 
    var rectA = (ne*sw); 
}) 


} 

功能listSelected(){

內部= $ .MAP(網站,功能(S){

var d; 

    if (((d = google.maps.geometry.poly.containsLocation(s.position)) <= rectA )) 
    return s.location + ' ('+(Math.round(d/100)/10)+' km)'; 
     $('#map-selected').html(inside.sort().join('')); 

})VAR;

} 


    google.maps.event.addListener(drawingManager, 'rectanglecomplete', function(rectangle) { 

    selectedArea = rectangle; 
    listSelected(); 

    google.maps.event.addListener(rectangle, 'center_changed', listSelected); 
    google.maps.event.addListener(rectangle, 'bounds_changed', listSelected);I am working with the Google maps API and I have a map I am drawing on with a rectangle. I need to have a user draw the rectangle, and on the map there will be predefined locations, that when the rectangle crosses the locations there will be details of each location put into a list. 

這是一個例子:

http://hmoodesigns.com/ksi/

我用圓圈繪製工具,我可以去做工精細的例子,但是矩形工具,我一直沒能有這確定了地圖上的點。

如何在頁面上沒有預定義的矩形的情況下檢查這些點?

感謝,

回答

0

當矩形已經繪就遍歷位置和使用的矩形的bounds測試是否經緯度的是矩形

的範圍內的方法