Skip to content

Instantly share code, notes, and snippets.

@advitum
Last active August 29, 2015 14:05
Show Gist options
  • Save advitum/5a2c317bc10d4137ce05 to your computer and use it in GitHub Desktop.
Save advitum/5a2c317bc10d4137ce05 to your computer and use it in GitHub Desktop.
How to display a google map.
//http://maps.google.com/maps/api/js?sensor=false
var position = [xxx, xxx];
$('#map').each(function() {
var map;
var latlng = new google.maps.LatLng(position[0], position[1]);
var center = new google.maps.LatLng(position[0], position[1]);
map = new google.maps.Map($(this).get(0), {
zoom: 9,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false,
navigationControl: false,
panControl: false,
zoomControl: false,
rotateControl: false,
mapTypeControl: false,
scaleControl: false,
overviewMapControl: false,
streetViewControl: false,
draggable: false,
styles: [
{
"stylers": [{ "saturation": -100 }]
}
]
});
var marker = {
map: map,
draggable: false,
animation: google.maps.Animation.DROP,
position: latlng,
title: 'xxx',
icon: new google.maps.MarkerImage('xxx')
};
setTimeout(function() {
new google.maps.Marker(marker);
}, 1000);
$(window).on('resize', function() {
google.maps.event.trigger(map, "resize");
map.setCenter(center);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment