Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manticorp/8434225fa8a93e943d1c to your computer and use it in GitHub Desktop.
Save manticorp/8434225fa8a93e943d1c to your computer and use it in GitHub Desktop.
Circles around n locations on a google map (for finding road signs)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geocoding service</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 1
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
//Locations (string), Distance in meters (float)
codeAddress("King's Lynn England",39*1609.344);
codeAddress("Holt England",6*1609.344);
codeAddress("Cromer England",4*1609.344);
}
function codeAddress(value,distance) {
geocoder.geocode( { 'address': value}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//map.setCenter(results[0].geometry.location);
var populationOptions = {
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: results[0].geometry.location,
radius: distance
};
// Add the circle for this city to the map.
cityCircle = new google.maps.Circle(populationOptions);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment