[英]Google Map Polygon Distance in Meters
How can I achieve this using the google map api? 如何使用Google Map API实现此目的?
http://i59.tinypic.com/6dzb88.jpg http://i59.tinypic.com/6dzb88.jpg
The meters on each side. 两侧的仪表。
If I right click on google maps distance, I can make something like this: http://i57.tinypic.com/21e7w1.jpg 如果我右键单击Google Maps距离,则可以进行如下操作: http : //i57.tinypic.com/21e7w1.jpg
Basically, I want the polygons I am drawing to look like the first or second image. 基本上,我希望绘制的多边形看起来像第一幅或第二幅图像。 (I need the labels) Is this possible?
(我需要标签)可以吗?
I am not sure if I understand your question correctly... But distance between two longitude/latitude points on a sphere can be calculated using http://en.wikipedia.org/wiki/Haversine_formula 我不确定我是否正确理解了您的问题...但是,可以使用http://en.wikipedia.org/wiki/Haversine_formula计算球体上两个经度/纬度点之间的距离
Javascript implementation JavaScript实现
rad = function(x) {return x*Math.PI/180;}
distHaversine = function(p1, p2) {
var R = 6371; // earth's mean radius in km
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong/2) * Math.sin(dLong/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d.toFixed(3);
}
I think there is also an implementation in the google maps api already though 我认为虽然Google Maps api中已经有一个实现
google.maps.geometry.spherical.computeDistanceBetween (latLngA, latLngB);
If you are having trouble drawing the polygons take a look at this here google maps example https://developers.google.com/maps/documentation/javascript/examples/polygon-simple 如果您在绘制多边形时遇到麻烦,请在此处查看google maps示例https://developers.google.com/maps/documentation/javascript/examples/polygon-simple
You would probably need to do some custom text overlays for the markers. 您可能需要为标记做一些自定义的文本覆盖。 Maybe using the the
MapLabel
class from: https://code.google.com/p/google-maps-utility-library-v3/ : 也许可以使用https://code.google.com/p/google-maps-utility-library-v3/中的
MapLabel
类:
var mapLabel = new MapLabel({
text: 'Test',
position: new google.maps.LatLng(50,50),
map: map,
fontSize: 20,
align: 'right'
});
Or you could simply create some custom polygons and draw them. 或者,您可以简单地创建一些自定义多边形并绘制它们。 Might be a bit of work for all numbers.
对于所有数字,可能都需要一些工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.