0

우리는 lat-long 목록을 가지고 있으며 Google지도에 표시하고 싶습니다. 여기에 위도와 경도의 목록이 있습니다.이 목록에 대한 Google지도를 생성 할 것을 기대합니다.위도와 경도 목록을 사용하여지도 영역을 생성 할 수있는 방법이 있습니까?

Input: 
12.123456, 72.123456 
12.123654, 72.366666 
.... 
.... 
12.123456, 72.123456 

Output: 

<code>area surround by red border is required output</code>

주 :이 입력은 참조에 대한 실제 데이터가 아닌 있습니다.

+1

다각형 5 월 당신을 도와줍니다. https://developers.google.com/maps/documentation/javascript/examples/polygon-arrays –

+0

예, poylogn! 또한, 4 점을 추가로 시도하면 (물론 당신이 할 것입니다.) [이 답변] (https://stackoverflow.com/questions/45056207/how-to-draw-a-polygon-in-google-map)을 확인하십시오. -using-many-coordinates/45060097 # 45060097) 줄 건너기 등을 피하기 위해 점수를 정렬하는 방법을 썼습니다. –

+0

감사합니다. @HardeepSingh Solved! 여기에 jsfiddle 링크 https://jsfiddle.net/rjnitt/12g7jL8y/2/ –

답변

0

당신은 교체해야합니다 당신의API_KEY출력을 제대로 확인합니다.

// This example creates a simple polygon representing the Bermuda Triangle. 
 

 
function initMap() { 
 
    var map = new google.maps.Map(document.getElementById('map'), { 
 
    zoom: 5, 
 
    center: {lat: 24.886, lng: -70.268}, 
 
    mapTypeId: 'terrain' 
 
    }); 
 

 
    // Define the LatLng coordinates for the polygon's path. 
 
    // Your coordinates should go here. 
 
    var triangleCoords = [ 
 
    {lat: 25.774, lng: -80.190}, 
 
    {lat: 18.466, lng: -66.118}, 
 
    {lat: 32.321, lng: -64.757}, 
 
    {lat: 25.774, lng: -80.190} 
 
    ]; 
 

 
    // Construct the polygon. 
 
    var bermudaTriangle = new google.maps.Polygon({ 
 
    paths: triangleCoords, 
 
    strokeColor: '#FF0000', 
 
    strokeOpacity: 0.8, 
 
    strokeWeight: 1, 
 
    fillColor: 'red', 
 
    fillOpacity: 0.1 
 
    }); 
 
    bermudaTriangle.setMap(map); 
 
}
/* Always set the map height explicitly to define the size of the div 
 
* element that contains the map. */ 
 
#map { 
 
    height: 100%; 
 
} 
 

 
/* Optional: Makes the sample page fill the window. */ 
 
html, body { 
 
    height: 100%; 
 
    margin: 0; 
 
    padding: 0; 
 
}
<div id="map"></div> 
 

 
<!-- Replace the value of the key parameter with your own API key. --> 
 
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initMap"> 
 
</script>