Created
June 5, 2012 07:16
-
-
Save rojan/2873288 to your computer and use it in GitHub Desktop.
Google map polygon
This file contains 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
<html> | |
<style> | |
html, body { | |
height: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
#map_canvas { | |
height: 80%; | |
width: 50%; | |
} | |
@media print { | |
html, body { | |
height: auto; | |
} | |
#map_canvas { | |
height: 650px; | |
} | |
} | |
</style> | |
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> | |
<script> | |
var geocoder = new google.maps.Geocoder(); | |
var map; | |
/* | |
* Initialize canvas | |
*/ | |
function initialize() { | |
var myLatlng = new google.maps.LatLng(40.7605505, -73.98226829999999); | |
var myOptions = { | |
zoom: 10, | |
center: myLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
showAddress(); | |
} | |
function showAddress() { | |
var zip_code = [ | |
//'10002', '10003', '10004', | |
//'10005', '10006', '10007', | |
//'10009', '10011', '10012', | |
//'10013', '10014', '10016', | |
//'10017', '10018', '10019', | |
//'10020', '10021', '10022', | |
//'10023', '10025', '10026', | |
//'10028', '10029', '10036', | |
//'10038', '10280', '19010' | |
]; | |
var zip_latlng = [ | |
['40.7135097', '-73.9859414', 'KNICKERBOCKER, NY 10002, USA'], | |
['40.7322535', '-73.98741050000001', 'Manhattan, NY 10003, USA'], | |
['40.7038704', '-74.0138541', 'BOWLING GREEN, NY 10004, USA'], | |
['40.6998433', '-74.00724359999998', 'WALL STREET, NY 10005, USA'], | |
['40.7022052', '-74.00210190000001', 'TRINITY, NY 10006, USA'], | |
['40.7136487', '-74.00871259999997', 'Manhattan, NY 10007, USA'], | |
['40.7275043', '-73.98006450000003', 'Manhattan, NY 10009, USA'], | |
['40.7464969', '-74.00944709999999', 'Manhattan, NY 10011, USA'], | |
['40.7250632', '-73.99769459999999', 'PRINCE, NY 10012, USA'], | |
['40.7217861', '-74.00944709999999', 'CANAL STREET, NY 10013, USA'], | |
['40.7366138', '-74.00944709999999', 'Manhattan, NY 10014, USA'], | |
['40.74727', '-73.98006450000003', 'Manhattan, NY 10016, USA'], | |
['40.7519846', '-73.96977950000002', 'Manhattan, NY 10017, USA'], | |
['40.7593941', '-73.96977950000002', 'Manhattan, NY 10022, USA'], | |
['40.755322', '-73.9932872', 'Manhattan, NY 10018, USA'], | |
['40.7605505', '-73.98226829999999', 'Manhattan, NY 10020, USA'], | |
['40.7700703', '-73.95802459999999', 'Manhattan, NY 10021, USA'], | |
['40.7686973', '-73.99181809999999', 'Manhattan, NY 10019, USA'], | |
['40.7602619', '-73.9932872', 'Manhattan, NY 10036, USA'], | |
['40.7769059', '-73.98006450000003', 'Manhattan, NY 10023, USA'], | |
['40.8017423', '-73.95508569999998', 'Manhattan, NY 10026, USA'], | |
['40.77664120000001', '-73.95214679999998', 'Manhattan, NY 10028, USA'], | |
['40.79164069999999', '-73.94479939999997', 'Manhattan, NY 10029, USA'], | |
['40.70962189999999', '-74.00210190000001', 'PECK SLIP, NY 10038, USA'], | |
['40.7075907', '-74.02266780000002', 'Manhattan, NY 10280, USA'], | |
['40.0252182', '-75.32372620000001', 'Bryn Mawr, PA 19010, USA'], | |
['40.7999209', '-73.96831020000002', 'Manhattan, NY 10025, USA'] | |
] | |
polygonCoords = [ | |
new google.maps.LatLng('40.703286','-74.017739'), | |
new google.maps.LatLng('40.735551','-74.010487'), | |
new google.maps.LatLng('40.752979','-74.007397'), | |
new google.maps.LatLng('40.808093','-73.966169'), | |
new google.maps.LatLng('40.794188','-73.931322'), | |
new google.maps.LatLng('40.783921','-73.94145'), | |
new google.maps.LatLng('40.776122','-73.941965'), | |
new google.maps.LatLng('40.739974','-73.972864'), | |
new google.maps.LatLng('40.729308','-73.971663'), | |
new google.maps.LatLng('40.711614','-73.978014'), | |
new google.maps.LatLng('40.706148','-74.00239'), | |
new google.maps.LatLng('40.702114','-74.009671'), | |
new google.maps.LatLng('40.701203','-74.015164') | |
] | |
makePolygon(polygonCoords); | |
} | |
/* | |
* add markers to the given lat lng | |
* | |
*/ | |
function makePolygon(polygonCoords) { | |
var polygon = new google.maps.Polygon({ | |
paths: polygonCoords, | |
strokeColor: "#FF0000", | |
strokeOpacity: 0.8, | |
strokeWeight: 2, | |
fillColor: "#FF0000", | |
fillOpacity: 0.35 | |
}); | |
polygon.setMap(map); | |
} | |
</script> | |
<body onload="initialize();"> | |
<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