Skip to content

Instantly share code, notes, and snippets.

View SpencerCooley's full-sized avatar

Spencer Cooley SpencerCooley

View GitHub Profile
<div id="map"></div>
body{
background-color:#f1f1f1;
}
#map{
width:100%;
height:400px;
}
$(document).ready(function(){
//creating an object literal containing the properties
var options = {
zoom: 3,
center: new google.maps.LatLng(37.09, -95.71),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//creating the map
var map = new google.maps.Map(document.getElementById('map'), options)
});
<html>
<head>
<title>A blank HTML5 page</title>
<meta charset="utf-8" />
<!--linked the stylsheet-->
<link rel="stylesheet" type="text/css" href="style.css" />
<!--included jquery from remote server-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<!-- include the google maps api sensor => false-->
<script type="text/javascript"
$(document).ready(function(){
//creating an object literal containing the properties
var options = {
zoom: 3,
center: new google.maps.LatLng(37.09, -95.71),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//creating the map
var map = new google.maps.Map(document.getElementById('map'), options);
});
var marker = new google.maps.Marker({
//this is just telling where on the map to drop the marker
position: new google.maps.LatLng(40.7257,-74.0047),
//tells which map to add it to. We named the map, map earlier
map:map,
//add title
title:'this marker is not draggable'
});
//now lets make a dragable marker.
var marker = new google.maps.Marker({
position: new google.maps.LatLng(40.7257,-75.5447),
map:map,
draggable:true,
title:'this marker is draggable'
});
// use a custom icon.
var marker = new google.maps.Marker({
position: new google.maps.LatLng(40.7257,-78.5447),
map:map,
draggable:true,
title:'this marker is draggable too, and you used your own image!!',
icon: 'marker1.png'
});
var infowindow = new google.maps.InfoWindow({
content: 'this is a custom marker! You can drag it!'
});
//create an infobox
var infowindow = new google.maps.InfoWindow({
content: 'this is an information box.<br> You can put anything inside of it.'
});