Create a marker on the edge of a circle using jQuery/Javascript/GM -
i have circle called "influence", want create marker on edge of circle. can't think of way of doing it.
my circle setup -
var influenceoptions = { strokecolor: "#00cc00", strokeopacity: 0.7, strokeweight: 0.5, fillcolor: "#00cc00", fillopacity: 0.35, map: map, center: latlng, radius: 30 }; influence = new google.maps.circle(influenceoptions);
how create marker on edge of circle?
update: http://jsfiddle.net/jaru2/4/
how add new marker edge of circle?
use
- math.random()* 360 random heading
- use google.maps.circle.getradius radius of circle
- use google.maps.geometry.spherical.computeoffset compute point @ random heading on circle. note: requires including geometry library
- make map variable global works
function addinfluence(latlng){ = new google.maps.marker({ map: map, position: latlng, }); var influenceoptions = { strokecolor: "#00cc00", strokeopacity: 0.7, strokeweight: 0.5, fillcolor: "#00cc00", fillopacity: 0.35, map: map, center: latlng, radius: 3000 }; influence = new google.maps.circle(influenceoptions); var bearing = math.random()*360; var newpoint = google.maps.geometry.spherical.computeoffset(latlng,influence.getradius(), bearing); var marker2 = new google.maps.marker({map:map, position:newpoint}); map.fitbounds(influence.getbounds()); }
Comments
Post a Comment