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

  1. math.random()* 360 random heading
  2. use google.maps.circle.getradius radius of circle
  3. use google.maps.geometry.spherical.computeoffset compute point @ random heading on circle. note: requires including geometry library
  4. make map variable global works

updated fiddle

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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -