我有以下代码段。
function initializeMap(nodeCoordinate) {
$("#map-canvas").css('margin-left','50');
var mapConstants = {
'MAP_ZOOM_LEVEL': 2,
'EMPTY_STRING': '',
'INITIAL_LATITUDE': -25.463882,
'INITIAL_LONGITUDE': 131.044922,
'INDEX_ZERO': 0,
'INDEX_ONE': 1
}
var myLatitudeLongitude = new google.maps.LatLng(mapConstants.INITIAL_LATITUDE, mapConstants.INITIAL_LONGITUDE);
var activityCoordinate = nodeCoordinate.coordinate;
var mapOptions = {
zoom: mapConstants.MAP_ZOOM_LEVEL,
center: myLatitudeLongitude
}
var loadMap = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
jQuery.each(activityCoordinate, function (activityIndex, activityValue) {
var activityAllCoordinate = activityValue.split(',');
if (nodeCoordinate.coordinate != undefined && nodeCoordinate.coordinate != mapConstants.EMPTY_STRING) {
myLatitudeLongitude = new google.maps.LatLng(activityAllCoordinate[mapConstants.INDEX_ZERO], activityAllCoordinate[mapConstants.INDEX_ONE]);
} else {
myLatitudeLongitude = new google.maps.LatLng(mapConstants.INITIAL_LATITUDE, mapConstants.INITIAL_LONGITUDE);
}
if (nodeCoordinate.coordinate != undefined && nodeCoordinate.coordinate != mapConstants.EMPTY_STRING) {
var markerOnMap = new google.maps.Marker({
position: myLatitudeLongitude,
map: loadMap,
title: nodeCoordinate.label
});
}
});
}
在上面的代码中我想给margin-left css属性映射。请帮助我如何给出它。在第2行,我试图这样做,但使用该行移动地图容器,但我正在寻找移动地图而不是整个容器。
答案 0 :(得分:0)
你可以试试这个:
$("#map-canvas .gm-style").css('left', 50);
或者:
$("#map-canvas .gm-style").css('margin-left', 50);
但请务必将其放在最后一个大括号之前的最后一行。
这只是一个建议,因为我真的不知道你想要实现的目标