here is code of java script :
<script>
function initMap() {
var lat = 10;
var lng = 10;
var propertyCenter = {lat: 10, lng: 10};
var propertymap = {
center: new google.maps.LatLng(lat, lng),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("propmap"), propertymap);
var marker = google.maps.Marker({
position: propertyCenter
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initMap);
</script>
I am getting following error on console :
js?key=my_key&callback=initMap:65 Uncaught TypeError: this.setValues is not a function
There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.
Go to the Credentials section, which can be accessed from the left side bar under Google Maps Platform > Credentials. Check that the API key you currently use on your website is listed. If that's not the case, switch to a different project, and check the credentials there.
Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.
Take a look at Map Markers Not Displaying (JavaScript/Google Maps API V3)
Try changing
var marker = google.maps.Marker
to
var marker = new google.maps.Marker
Adding new
should fix your issue
This also applies to the library load-google-maps-api
for those using webpack.
loadGoogleMapsAPI().then((googleMaps) => {
new googleMaps.Map(element, {options})
}).catch((err) => {
console.error(err)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With