Answer the question
In order to leave comments, you need to log in
Why does everything move from the given coordinates when the map is scaled up?
I have several different cards. When you click on the link, I show the map with the given coordinates and put a marker on this place! But when I start to increase the zoom, the marker shifts!
//инициализация карты
var mapModule = (function(){
'use strict';
var mapSection = $('#map')[0];
return {
// Добавим маркер
addMarker: function(latitude, longitude, map){
new google.maps.Marker({
position: {
lat: latitude,
lng: longitude
},
icon: new google.maps.MarkerImage('/images/mapMarker.png',
new google.maps.Size(84,95),
new google.maps.Point(0,0),
new google.maps.Point(0,95)
),
map: map
});
},
// Инициализация карты
initMap: function(latitude, longitude) {
var mapPosition = new google.maps.LatLng(latitude, longitude),
mapOptions = {
zoom: 14,
center: mapPosition,
scaleControl: false,
zoomControl: false,
streetViewControl: false,
mapTypeControl: false
},
map = new google.maps.Map(mapSection, mapOptions);
mapModule.addMarker(latitude, longitude, map);
}
}
}());
// Открытие карты с заданными координатами
$('.showMap').on('click', function(event){
event.preventDefault();
$('.showMap').removeClass('act');
$(this).addClass('act');
var latitude = $(this).data('latitude'),
longitude = $(this).data('longitude');
mapModule.initMap(latitude, longitude);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question