2012-04-01 2 views
0

포인트 사이의 거리를 계산하여 gps 포인트를 필터링하고 (표시된 포인트 수 줄임) 거리가 300 미터 미만인 경우 맵에 다음 포인트를 추가하지 않습니다. 여기거리로 필터링하는 맵 포인트

는 마커와 폴리 라인

var json = jQuery.parseJSON(data); 
      jQuery("#gMap").gmap3({ action: 'clear' }); 
      jQuery(".marker").remove(); 
      var counts = 0; 

      jQuery.each(json, function(i, item) { 
       var polyArray=[]; 
       var name = item.name; 
       var userId = item.data.user; 
       jQuery.each(item.data.data, function(i, nav) { 
        var ts = nav.timestamp; 
        var lat = nav.latitude; 
        var long = nav.longitude; 

        if (lat != null && long != null) { 
         addMarker(name, counts = counts + 1, ts, lat, long, userId); 
         polyArray.push([ lat, long]); 
        } 
        addPolyline(polyArray, get_random_color()); 
       }); 

      }) 

을 만들 수있는 내 현재 자바 스크립트입니다 그리고 이것은 내가 위를 달성하는 데 사용되는 PHP에서 내 이전 버전입니다 - 난 내 자바 스크립트에서 같은 작업을 수행 할 수있는 방법?

<?php 

       $old_lat = $old_long = "0"; 
       $data = array(); 

       foreach($history['data'] as $i => $record) { 
        $distance = distance($record['latitude'], $record['longitude'], $old_lat, $old_long, "V"); 

         if($distance >= $_SESSION['same_position']) { 
         $last_i = $i; 
         $data[$i] = $record; 
          $old_lat = $record['latitude']; 
          $old_long = $record['longitude']; 
         } else { 
         $data[$last_i]['to_timestamp'] = $record['timestamp']; 
          $old_lat = $record['latitude']; 
          $old_long = $record['longitude']; 
         } 

       } 

       foreach($data as $record) { 
       echo 'add(jQuery(this), number += 1, "' . $record['timestamp'] . '", "' . $name . '", "' . $history['user'] . '", "' . $record['latitude'] . '", "' . $record['longitude'] . '", "' . $record['to_timestamp'] . '");'; 
       } 

        ?> 

건배!

+0

당신이 포인트 계산 사이의 실제 거리에 문제가있는, 아니면 그냥 자바 스크립트를 구현하는 항목입니다

그러나 형상 라이브러리를 사용하여 클라이언트 측에 거리를 계산할 수있다? – Douglas

+0

나는 google.maps.geometry.spherical.computeDistanceBetween()을 사용하여 차이를 잘 계산할 수 있습니다. 그것의 단지 자바 스크립트 버전 작업을 만들고있어. –

답변

관련 문제