I am trying to draw a circle with a dashed border in google maps.
I have a function draw circle which return me the sets of lat,lngs and I use google maps polygon API for the drawing of a circle, but the border comes as a joint line, not a dashed one.
Any idea ?
I am posting my code for reference :
function drawCircle(point, radius, dir) {
var d2r = Math.PI / 180; // degrees to radians
var r2d = 180 / Math.PI; // radians to degrees
var earthsradius = 3963; // 3963 is the radius of the earth in miles
var points = 32;
// find the raidus in lat/lon
var rlat = (radius / earthsradius) * r2d;
var rlng = rlat / Math.cos(point.lat() * d2r);
var extp = new Array();
if (dir === 1) {
var start = 0;
var end = points + 1; // one extra here makes sure we connect the path
} else {
var start = points + 1;
var end = 0;
}
for (var i = start; (dir === 1 ? i < end : i > end); i = i + dir)
{
var theta = Math.PI * (i / (points/2));
ey = point.lng() + (rlng * Math.cos(theta)); // center a + radius x * cos(theta)
ex = point.lat() + (rlat * Math.sin(theta)); // center b + radius y * sin(theta)
extp.push(new google.maps.LatLng(ex, ey));
}
return extp;
}
var lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4
};
var circle = new google.maps.Polygon({
path: drawCircle(new google.maps.LatLng
(center.latitude,
center.longitude),
radius/1609.344, 1),
strokeOpacity: 0.5,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '20px'
}],
strokeWeight: 2,
strokeColor: '#ffcb00',
fillColor: '#ffcb00',
fillOpacity: 0.1
});
return circle ;