Reputation: 11
I am trying to add a marker to a map in Google maps using JavaScript. The console on from Google Chrome is returning "Uncaught TypeError: undefined is not a function"
. The error appears right after the map = new google.maps.Map
. However if I take out the Marker code the map appears and there are no errors.
The code I am using is
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCs7h9k3_PHQpo8EBDf-GaVhf178Z3xSb4&sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(35.6017, -77.3725)
};
map = new google.maps.Map(document.getElementById('gmap'),
mapOptions);
var marker = new google.maps.Marker({
position: new google.maps.Latlng(36, -77),
map: map,
title: 'Test'
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Upvotes: 0
Views: 163
Reputation: 5472
position: new google.maps.Latlng(36, -77),
to
position: new google.maps.LatLng(36, -77),
Upvotes: 1