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>
position: new google.maps.Latlng(36, -77),
至
position: new google.maps.LatLng(36, -77),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.