Skip to content

Instantly share code, notes, and snippets.

@ryarwood
Created November 6, 2012 01:58
Show Gist options
  • Save ryarwood/4022027 to your computer and use it in GitHub Desktop.
Save ryarwood/4022027 to your computer and use it in GitHub Desktop.
Google Map API v3 Ghetto Example
function initialize() {
var myOptions = {
zoom: 11,
center: new google.maps.LatLng(37.392391,-122.059822),
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
/* THE MARKER */
var image = '/images/now_open.png';
var myLatLng = new google.maps.LatLng(37.392152,-122.072041);
var contentString = '<div style="height: 180px;"><h1 style="font-size: 17px; margin: 0px 5px 0px 0px; padding: 0px 0px 0px 0px;">Classics at Station 361</h1><h2 style="font-size: 15px; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">NOW OPEN</h2><p>Townhomes and Single-family homes in<br />Downtown Mountain View</p><p>209 W Evelyn Ave<br />Mountain View, CA 94041</p><p><a href="http://classicsstation361.com/" style="display: block; padding: 4px 10px 4px 10px; text-align: center; width: 160px; background-color: #e56f00; color: #FFFFFF; text-decoration: none; font-size: 13px;">Visit Website &gt;</a></p></div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var beachMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
title: 'Classics at Station 361'
});
google.maps.event.addListener(beachMarker, 'click', function() {
infowindowTwo.close();
infowindow.open(map,beachMarker);
});
/* THE MARKER TWO */
var imageTwo = '/images/coming_soon.png';
var myLatLngTwo = new google.maps.LatLng(37.400918,-122.016003);
var contentStringTwo = '<h1 style="font-size: 17px; margin: 0px 5px 0px 0px; padding: 0px 0px 0px 0px;">Classics at Tasman Crossing</h1><h2 style="font-size: 15px; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">COMING LATE 2012</h2><p>17 Townhomes in Sunnyvale</p><p>1060 Morse Ave<br />Sunnyvale, CA 94089</p>';
var infowindowTwo = new google.maps.InfoWindow({
content: contentStringTwo
});
var beachMarkerTwo = new google.maps.Marker({
position: myLatLngTwo,
map: map,
icon: imageTwo,
title: 'Classics at Tasman Crossing'
});
google.maps.event.addListener(beachMarkerTwo, 'click', function() {
infowindow.close();
infowindowTwo.open(map,beachMarkerTwo);
});
}
$(document).ready(function() {
initialize();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment