Last active
June 15, 2018 18:06
-
-
Save raulmangolin/fa2fb18f4fe8dd632af73b3856c9679a to your computer and use it in GitHub Desktop.
Google Maps City Bounds - http://raulmangolin.com/tests/bounds.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<style type="text/css"> | |
html,body { height: 100%; margin: 0px; padding: 0px; } | |
#map_canvas { | |
width:100%; | |
height:600px; | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyD0X4v7eqMFcWCR-VZAJwEMfb47id9IZao"></script> | |
<script type="text/javascript"> | |
var map; | |
var CityHightlight = false; | |
var coordSL = [[-44.434,-2.8],[-44.401,-2.796],[-44.389,-2.797],[-44.388,-2.765],[-44.366,-2.756],[-44.3630171,-2.7564169],[-44.3614806,-2.7573249],[-44.3604507,-2.7590645],[-44.3598963,-2.7612433],[-44.359,-2.763],[-44.3569882,-2.7637027],[-44.3502831,-2.7628967],[-44.345,-2.765],[-44.3378376,-2.7703767],[-44.328,-2.782],[-44.307,-2.779],[-44.281,-2.766],[-44.278,-2.764],[-44.252,-2.752],[-44.184,-2.737],[-44.1629785,-2.73],[-44.1819785,-2.692],[-44.1699785,-2.68],[-44.1739785,-2.67],[-44.1689785,-2.649],[-44.1739785,-2.652],[-44.1809785,-2.649],[-44.1849785,-2.638],[-44.1839785,-2.631],[-44.1809785,-2.625],[-44.1669785,-2.596],[-44.1779785,-2.583],[-44.1959785,-2.562],[-44.2069785,-2.566],[-44.2059785,-2.553],[-44.2079785,-2.554],[-44.2094616,-2.5511146],[-44.2062563,-2.5501415],[-44.2067499,-2.5483409],[-44.2075331,-2.5467224],[-44.2043788,-2.5460472],[-44.203274,-2.5456935],[-44.2035019,-2.544774],[-44.2037182,-2.543792],[-44.2040902,-2.5420366],[-44.2023081,-2.5416741],[-44.19527,-2.5401736],[-44.1972477,-2.5314636],[-44.2010886,-2.5318709],[-44.2025477,-2.5323639],[-44.2032344,-2.5322996],[-44.2043931,-2.5326855],[-44.2049939,-2.5310777],[-44.2061955,-2.5281837],[-44.2041785,-2.5265117],[-44.2038566,-2.5249253],[-44.2035992,-2.523682],[-44.2057664,-2.5217098],[-44.2052085,-2.5211739],[-44.2041785,-2.5212382],[-44.2023332,-2.5220957],[-44.2012388,-2.5220314],[-44.201153,-2.5197376],[-44.2089785,-2.48],[-44.2159785,-2.471],[-44.227,-2.478],[-44.26,-2.481],[-44.2659271,-2.4837766],[-44.295,-2.485],[-44.3038951,-2.4876264],[-44.311,-2.497],[-44.326,-2.5],[-44.374,-2.454],[-44.387,-2.478],[-44.399,-2.5],[-44.423,-2.58],[-44.426,-2.591],[-44.431,-2.621],[-44.43,-2.644],[-44.425,-2.685],[-44.431,-2.735],[-44.432,-2.766],[-44.434,-2.8]]; | |
var coordNR = [[-43.995,-3.478],[-43.986,-3.493],[-43.984,-3.501],[-43.901,-3.49],[-43.813,-3.477],[-43.798,-3.476],[-43.797,-3.481],[-43.788,-3.49],[-43.787,-3.501],[-43.779,-3.508],[-43.775,-3.52],[-43.774,-3.526],[-43.765,-3.535],[-43.755,-3.536],[-43.751,-3.54],[-43.751,-3.547],[-43.748,-3.545],[-43.75,-3.539],[-43.739,-3.538],[-43.738,-3.545],[-43.73,-3.546],[-43.727,-3.551],[-43.71,-3.559],[-43.715,-3.567],[-43.708,-3.571],[-43.701,-3.579],[-43.69,-3.58],[-43.688,-3.575],[-43.678,-3.583],[-43.659,-3.588],[-43.657,-3.578],[-43.652,-3.577],[-43.648,-3.581],[-43.644,-3.604],[-43.632,-3.612],[-43.626,-3.603],[-43.622,-3.604],[-43.617,-3.61],[-43.615,-3.62],[-43.606,-3.618],[-43.646,-3.562],[-43.675,-3.52],[-43.729,-3.442],[-43.736,-3.439],[-43.737,-3.432],[-43.739,-3.429],[-43.732,-3.425],[-43.732,-3.42],[-43.717,-3.409],[-43.715,-3.399],[-43.726,-3.382],[-43.736,-3.385],[-43.745,-3.378],[-43.744,-3.365],[-43.748,-3.353],[-43.75,-3.348],[-43.755,-3.346],[-43.756,-3.335],[-43.764,-3.323],[-43.768,-3.32],[-43.787,-3.332],[-43.796,-3.329],[-43.804,-3.315],[-43.805,-3.301],[-43.8,-3.299],[-43.799,-3.292],[-43.8,-3.283],[-43.793,-3.273],[-43.79,-3.259],[-43.779,-3.255],[-43.775,-3.248],[-43.775,-3.237],[-43.783,-3.224],[-43.783,-3.213],[-43.857,-3.306],[-43.895,-3.355],[-43.896,-3.357],[-43.945,-3.42],[-43.944,-3.412],[-43.955,-3.413],[-43.967,-3.431],[-43.968,-3.441],[-43.975,-3.446],[-43.974,-3.454],[-43.98,-3.463],[-43.988,-3.465],[-43.995,-3.478]]; | |
var coordMorro = [[-44.067316,-2.8904917],[-44.0668783,-2.894302],[-44.0626383,-2.8991581],[-44.05,-2.893],[-44.034,-2.898],[-44.036,-2.903],[-44.029,-2.904],[-44.021,-2.923],[-44.028,-2.947],[-44.02,-2.957],[-44.008,-2.962],[-44.003,-2.98],[-43.996,-2.988],[-43.96,-3.01],[-43.948,-3.015],[-43.931,-3.018],[-43.9,-3.033],[-43.896,-3.038],[-43.893,-3.043],[-43.885,-3.05],[-43.857,-3.063],[-43.839,-3.068],[-43.814,-3.079],[-43.782,-3.084],[-43.775,-3.094],[-43.769,-3.095],[-43.763,-3.103],[-43.763,-3.114],[-43.757,-3.121],[-43.752,-3.135],[-43.755,-3.155],[-43.759,-3.161],[-43.755,-3.173],[-43.759,-3.182],[-43.769,-3.193],[-43.774,-3.206],[-43.783,-3.213],[-43.783,-3.224],[-43.775,-3.237],[-43.775,-3.248],[-43.779,-3.255],[-43.79,-3.259],[-43.793,-3.273],[-43.8,-3.283],[-43.799,-3.292],[-43.783,-3.292],[-43.679,-3.222],[-43.606,-3.172],[-43.551,-3.136],[-43.542,-3.129],[-43.547,-3.113],[-43.571,-3.038],[-43.598,-2.963],[-43.599,-2.963],[-43.614,-2.928],[-43.621,-2.914],[-43.633,-2.886],[-43.641,-2.87],[-43.712,-2.711],[-43.745,-2.637],[-43.745,-2.679],[-43.745,-2.807],[-43.755,-2.807],[-43.811,-2.808],[-43.818,-2.808],[-44.019,-2.808],[-44.05,-2.808],[-44.051,-2.836],[-44.051,-2.841],[-44.053,-2.848],[-44.05,-2.861],[-44.0500641,-2.8643078],[-44.048635,-2.8662665],[-44.0442404,-2.8655293],[-44.0444293,-2.8684396],[-44.0454979,-2.870647],[-44.0476222,-2.8720057],[-44.0525102,-2.8745388],[-44.0616898,-2.8775005],[-44.0631232,-2.8843497],[-44.0649771,-2.8872257],[-44.067316,-2.8904917]]; | |
$(document).ready(function () { | |
var latlng = new google.maps.LatLng(-2.8, -44.434); | |
var myOptions = { | |
zoom:9, | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
}); | |
function addBounds(data) { | |
if(CityHightlight) { | |
CityHightlight.setMap(null); | |
} | |
var cityBounds = []; | |
for(var i = 0; i < data.length; i++ ) { | |
cityBounds.push(new google.maps.LatLng(data[i][1], data[i][0])) | |
} | |
CityHightlight = new google.maps.Polygon({ | |
paths: cityBounds, | |
strokeColor: "#6666FF", | |
strokeOpacity: 0.8, | |
strokeWeight: 2, | |
fillColor: "transparent", | |
}); | |
CityHightlight.setMap(map); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="map_canvas"></div> | |
<br><br><br> | |
<button onclick="addBounds(coordSL)">Adicionar marcar em São Luis</button> | |
<button onclick="addBounds(coordNR)">Adicionar marcar em Nina Rodrigues</button> | |
<button onclick="addBounds(coordMorro)">Adicionar marcar em Morros</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: http://raulmangolin.com/tests/bounds.html