2014-04-29 2 views
0

Google지도에서 내 맞춤 마커를 선택할 수 있도록지도에서 원을 그려서 프로젝트를 진행하고 있습니다. 포괄 된 원의 모든 마커를 선택해야합니다. 다음은 어떻게 진행될 것인가입니다 :Google지도에서 원을 그려서 맞춤 마커를 선택하십시오.

1. User clicks at a point on googlemaps and draws a circle. 
2. The circle encompasses the custom markers. 
3. All the custom markers are selected. 

나는이 3 가지 단계를 거쳐야합니다.

도움이 필요합니다.

+0

어떤 문제가 있습니까? 지금까지 뭐 했니? – geocodezip

+0

마커를 Google지도에 추가했습니다. 또한이 코드를 사용하여 원을 그렸습니다. 이제 내 서클 아래에서 위치를 선택하는 방법에 대해 혼란스러워합니다. – darthsidious

+0

중심에서 떨어진 원의 반경보다 작은 위치는 원 안에 있습니다. – geocodezip

답변

2

가능한 워크 플로우 : 당신이 마커를 만들 때

  1. 는, 객체에 저장 (재산-이름으로 아이디의 사용).
    샘플 :

    markers = { 
        1: new google.maps.Marker(/*properties*/), 
        2: new google.maps.Marker(/*properties*/), 
        5: new google.maps.Marker(/*properties*/) 
    } 
    
  2. Circle가 그려져 radiusmarkers -Properties 위에 원
  3. 반복 처리의 center 페치 및 마커 google.maps.geometry.spherical.computeDistanceBetween 필터링을 사용한다. 배열에서 필터링 된 마커의 ID의 보관 :

    var IDs=[]; 
    
    for(var k in markers){ 
        if(google.maps.geometry.spherical 
         .computeDistanceBetween(circleCenter,markers[k].getPosition()) 
          <=circleRadius){ 
         IDs.push(k); 
        } 
    } 
    
  4. 이 서버 측 스크립트에 ID를 배열을 보내기 .....
  5. 참고

:geometry -library가로드되지 기본적으로 https://developers.google.com/maps/documentation/javascript/libraries을 참조하십시오.

+0

정말 멋집니다. 나는 기본적인 것을 얻었지만 이벤트를 일으켜야하는 원을 그리면 바로 ID를 추출 할 수 있기를 바랍니다. 나는 1 일 자바 스크립트 사람이므로 힌트가 필요하다. – darthsidious

+0

google.maps.event.addListener (map, 'click', function (e))가 있습니다. 희망입니다. – darthsidious

+0

그림 라이브러리를 사용한다고 가정하면 : ['circle_complete'] (https : /developers.google.com/maps/documentation/javascript/drawing#drawing_events)-event –

관련 문제