I’ve been searching for hours but cannot find a solution. My marker code is very simple (grabbed from the api documentation) but I cannot seem to get the marker to show up on my website. Map itself renders fine (key is included in actual code) but with no marker.
Any help would be appreciated. Thanks!
Site: http://ath-uterwinctr.its.utexas.edu/about/location
Code in file (gmap.js) referenced by website:
$(document).ready(function(){
var myLatLng = new google.maps.LatLng(30.27639, -97.732422);
var myOptions = {
center: myLatLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-erwincenter"),
myOptions);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: "Frank Erwin Center"
});
});
Website Code referencing gmap.js:
<?php
drupal_add_js('sites/all/themes/delphic/js/gmap.js');
drupal_set_html_head('<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script>'); ?>
<div id="map-frame"><div id="map-erwincenter"> </div></div>
I looked at your live source, you need to remove the line
marker.setMap(). The marker will already place itself in your map with themap: mapproperty defined above.Calling
setMapwould have to be done asmarker.setMap(map), but it is redundant and unnecessary because ofmap: mapbeing in the options. I think what’s happening right now issetMap()is interpreted assetMap(null)and the effect is removing your marker.http://ath-uterwinctr.its.utexas.edu/sites/default/files/js/js_40f5a94093acf14755eb100d58a7a838.js
Line 1245