Skip to content Skip to sidebar Skip to footer

Drawing Anonymous Circles In Google Maps

I'm trying to draw a google maps that has multiple Circle overlays, however I do not want to reveal the correct center of the radius. So for example, myLatlng is my lat/lon center

Solution 1:

In your example code. The circle could move anywhere such that 33.3 and 22.2 could still be included.

One way to do this would be to simply add a random offset.

// Generate random between -5 and 5 (just an example)var latOffset = Math.floor(Math.random()*11) - 5;
    var longOffset = Math.floor(Math.random()*11) - 5;
    var myLatlng = new google.maps.LatLng(33.33333 + latOffset,22.22222 + longOffset);

The tricky bit you've got is to ensure that the random offset doesn't move the circle out of bounds. The section Expressing latitude and longitude as linear units on Wikipedia should help.

Post a Comment for "Drawing Anonymous Circles In Google Maps"