0

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>   

1 Answer 1

1
position: new google.maps.Latlng(36, -77),

to

position: new google.maps.LatLng(36, -77),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.