- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试了很多,但无法找出问题所在。我想围绕特定的纬度、经度绘制一个多边形。多边形将由特定半径内的 13 个坐标组成。
代码
function showAddress(address, miles) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
address : address
}, function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
//searchLocationsNear(results[0].geometry.location);
var cordinate = results[0].geometry.location;
//alert(cordinate);
var mapOptions = {
center : cordinate,
zoom : 8,
mapTypeId : google.maps.MapTypeId.ROADMAP,
overviewMapControl : true,
overviewMapControlOptions : {
opened : true,
position : google.maps.ControlPosition.BOTTOM_LEFT
}
};
//
//var address = document.getElementById("address").value;
var radius = 1;
var latitude = 23.1793013;
var longitude = 75.78490970000007;
//Degrees to radians
var d2r = Math.PI / 180;
// Radians to degrees
var r2d = 180 / Math.PI;
// Earth radius is 3,963 miles
var cLat = (radius / 3963) * r2d;
var cLng = cLat / Math.cos(latitude * d2r);
//Store points in array
var points = [];
alert("declare array");
var bounds = new google.maps.LatLngBounds();
// Calculate the points
// Work around 360 points on circle
for(var i = 0; i < 13; i++) {
var theta = Math.PI * (i / 180);
// Calculate next X point
circleY = longitude + (cLng * Math.cos(theta));
//console.log("CircleY:"+circleY);
// Calculate next Y point
circleX = latitude + (cLat * Math.sin(theta));
//console.log("circleX:"+circleX);
// Add point to array
var aPoint = new google.maps.LatLng(circleX, circleY);
points.push(aPoint);
bounds.extend(aPoint);
}
points.push(points[0]);
//console.log(points);
//to complete circle
var colors = ["#CD0000", "#2E6444", "#003F87"];
var Polyline_Path = new google.maps.Polyline({
path : points,
strokeColor : colors[0],
// color of the outline of the polygon
strokeOpacity : 1,
// between 0.0 and 1.0
strokeWeight : 1,
// The stroke width in pixels
fillColor : colors[1],
fillOpacity : 0
});
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
Polyline_Path.setMap(map);
} else {
alert(address + ' not found');
}
});
}
最佳答案
替换i<13;i++
通过
i<360;i+=360/13
这会起作用
谢谢
编辑:不需要最后一点,因为 gmap 会自动关闭它
关于javascript - 围绕中心点绘制多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19691765/
如何让div的中心点作为旋转的中心点。 我遇到了 this虽然我正在做一些研究,但我似乎无法将其融入我的研究。 这就是帖子所建议的。但不起作用。$(area).css('-webkit-transfo
您好,我正在做一个应用程序,在我的应用程序中有一个 map 页面,所以我实现了 Google Maps V2,我遇到了一个问题,当我滚动 map 时,我想获得 map 的中心点,如果我滚动 map ,
我正在玩一个简单的 2d 游戏,我正在尝试从级别 1(场景一)切换到级别 2(场景二)。为了测试,两个级别包含相同的内容。这是我的转换代码: let transition = SKTransi
我有一个覆盖大部分屏幕区域的 map 的 View 。 在 map 的顶部,我有一些图像、按钮、文本框。它们位于 map 的顶部,我在这里称其为“无用 map ”,而底部则用于实际查看 map 。这是
给定一个纯白色背景上的对象,有人知道 OpenCV 是否提供了从捕获的帧中轻松检测对象的功能吗? 我正在尝试定位对象(矩形)的角点/中心点。我目前这样做的方式是通过蛮力(扫描对象的图像)并且不准确。我
我试图确保我的 map 中心点位于 kml 层的边界内,我无法找到很多相关信息,但我修改了来自 here 的一些代码。这似乎可行,但当然行不通。 从 Google Maps API 中,我无法判断 .
我试图在用户滚动 UIScrollView 时创建一个非常简单的视差效果。我在我的 ScrollView 上使用 scrollViewDidScroll 方法,一切正常。我可以记录该方法的所有内容,因
我正在使用 svg.js 和出色的 svg-pan-zoom 插件 ( https://github.com/ariutta/svg-pan-zoom )。 现在我想要一个按钮,当我单击它时,它会在我
我是一名优秀的程序员,十分优秀!