Skip to content

Instantly share code, notes, and snippets.

@rojan
Created May 30, 2012 17:22
Show Gist options
  • Save rojan/2837761 to your computer and use it in GitHub Desktop.
Save rojan/2837761 to your computer and use it in GitHub Desktop.
multiple marker Google map api
<html>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map_canvas {
height: 50%;
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']
]
for (var i=0; i < zip_latlng.length; i++) {
//console.log(zip_latlng[i][0]);
//console.log(zip_latlng[i][1]);
makeMarker(zip_latlng[i][0], zip_latlng[i][1], zip_latlng[i][2]);
}
}
/*
* add markers to the given lat lng
*
*/
function makeMarker(lat, lng, address) {
//console.log(lat);
//console.log(lng);
var myLatlng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: address
});
}
</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