Skip to content

Instantly share code, notes, and snippets.

@joeldom
Last active August 29, 2015 14:07
Show Gist options
  • Save joeldom/cc81e4535a53a5171340 to your computer and use it in GitHub Desktop.
Save joeldom/cc81e4535a53a5171340 to your computer and use it in GitHub Desktop.
Need help adding a marker to the map.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="sitkobrunomap" style="height:200px;width:100%;"></div>
<script type="text/javascript">
function init_map(){
var stylesArray = [
{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"off"}]},
{"featureType":"all","elementType":"geometry.fill","stylers":[{"saturation":-100}]},
{"featureType":"transit","elementType":"labels","stylers":[{"visibility":"off"}]},
{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":30}]},
{"featureType":"water","elementType":"geometry.fill","stylers":[{"hue":"#4c639e"},{"lightness":-37}]},
{"featureType":"road","elementType":"labels","stylers":[{"weight":2.44},{"saturation":-85},{"gamma":0.75}]},
{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"lightness":-10}]},
{"featureType":"water","elementType":"labels","stylers":[{"saturation":-100},{"lightness":-11}]},
{"featureType":"poi","elementType":"labels","stylers":[{"visibility":"on"},{"saturation":-73},{"lightness":-10}]}
]
var myOptions = {
zoom:14,
center:new google.maps.LatLng(<?php echo $adds['lat']; ?>, <?php echo $adds['lng']; ?>),
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
scrollwheel: false,
panControl: false,
zoomControl: true,
zoomControlOptions: {
style: google.maps.MapTypeControlStyle.SMALL,
postion: google.maps.ControlPosition.TOP_LEFT
},
scaleControl: true,
overviewMapControl: false
};
map = new google.maps.Map(document.getElementById("sitkobrunomap"), myOptions);
map.setOptions({styles: stylesArray});
var pinLocation = new google.maps.LatLng(<?php echo $adds['lat']; ?>, <?php echo $adds['lng']; ?>)
marker = new google.maps.Marker({
map: map,
position: pinLocation,
icon: "client image directory withheld"
});
var contentString = '<b>Client Name</b><br/>Client Address';
var infowindow = new google.maps.InfoWindow({ content: contentString });
google.maps.event.addListener(marker, 'click', function(){infowindow.open(map,marker);});}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment