Answer the question
In order to leave comments, you need to log in
Google map markers move when moving the mouse, how can I fix this?
Hello everyone, when you zoom in or move the mouse around the map, the markers move with you!
I can not find the error, if you help, I will be grateful)
https://codepen.io/lycorp/pen/NyBJEX - source
Answer the question
In order to leave comments, you need to log in
At you 2 times object "map" is created. Line 149 ( var mapOptions = ...
) actually creates an object not with map options, but a completely finished map. The second call new google.maps.Map()
, and even with inadequate options, just breaks everything.
The corrected one will look like this:
// store map locations list wrapper.
var mapLocationsEl = $('.map-locations');
// create a map object, and include the MapTypeId to add to the map type control.
var map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: 56.3010164,
lng: 43.9399994
},
streetViewControl: 0,
gestureHandling: 'cooperative',
zoom: 12
});
// associate the styled map with the MapTypeId and set it to display.
map.mapTypes.set('map_style', styledMap);
map.setMapTypeId('map_style');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question