Last active
August 29, 2015 14:21
-
-
Save reimertz/ee69f0b0b98b30e829bf to your computer and use it in GitHub Desktop.
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
//On my own homepage, I wanted to create a icon marker on Vänersborg, my hometown. | |
//According to Google Maps API, polygons should be easy to add as well. | |
//here is the implementation: http://www.reimertz.co/me/ | |
google.maps.event.addDomListener(window, 'load', init); | |
var map; | |
function init() { | |
var mapOptions = { | |
zoom: 12, | |
zoomControl: false, | |
disableDoubleClickZoom: false, | |
mapTypeControl: false, | |
scaleControl: false, | |
scrollwheel: false, | |
panControl: false, | |
streetViewControl: false, | |
draggable: false, | |
overviewMapControl: false, | |
overviewMapControlOptions: { | |
opened: false, | |
}, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
styles: [{ .... }) | |
}; | |
var mapElement = document.getElementById('google-maps'); | |
map = new google.maps.Map(mapElement, mapOptions); | |
marker = new google.maps.Marker({ | |
icon: 'https://mapbuildr.com/assets/img/markers/ellipse-black.png', | |
position: new google.maps.LatLng(58.3797283, 12.32480320000002), | |
map: map, | |
text: 'I\'m from here' | |
}); | |
function recalculateMapPosition() { | |
map.setCenter(mapOptions.center); | |
map.panBy(-($(window).width() / 2) + 75, ($(window).height() / 2) - 75); | |
} | |
$(window).on('resize', recalculateMapPosition); | |
recalculateMapPosition(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment