N
N
Nikita Shchypylov2017-06-27 10:24:50
JavaScript
Nikita Shchypylov, 2017-06-27 10:24:50

Why does the marker change its location to zoom?

I have this marker:

var image = '/img/map-marker.png';
var mainOfficeDot = {lat: 50.443718, lng: 30.652011};

var marker = new google.maps.Marker({
    position: mainOfficeDot,
    anchor: mainOfficeDot,
    map: map,
    icon: image
});

//init map
var map = new google.maps.Map(document.getElementById('js-contacts-map'), {
    zoom: 13,
    scrollwheel: false,
    center: mainOfficeDot 
});

When you click on +/- (zoom), it changes its location, and drastically. At the country level, he moves to Georgia. What have I done wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Moskus, 2017-06-27
@Moskus

To begin with, remove anchor, you don't know what you use this property for, passing to it, for some reason, geographic coordinates.

F
freeExec, 2017-06-27
@freeExec

And you tied the marker to a non-existent map.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question