Google Maps V3 Circle & Circle that I created do not match

后端 未结 2 1557
情深已故
情深已故 2021-01-12 13:31

I created a circle using the Google Maps V3 API and also tried to make a circle of markers with the same radius.

Problem: The one I created is obli

2条回答
  •  滥情空心
    2021-01-12 14:33

    To calculate distances on a sphere, you can utilize Google Maps geometry library. To request the library use:

    
    

    Then, your circle JS code would be:

    num_theta_step = 365;               // number of steps
    for(theta = 0; theta < 365; theta += 365/num_theta_step) {                        
       var circle_latlng = google.maps.geometry.spherical.computeOffset(target_latlng, R, theta);
       var marker = new google.maps.Marker({
          position: circle_latlng,
          map: map,
          title:"Hello World!"
       });
    }
    

提交回复
热议问题