Google maps 更改谷歌地图css
我有以下代码段Google maps 更改谷歌地图css,google-maps,Google Maps,我有以下代码段 function initializeMap(nodeCoordinate) { $("#map-canvas").css('margin-left','50'); var mapConstants = { 'MAP_ZOOM_LEVEL': 2, 'EMPTY_STRING': '', 'INITIAL_LATITUDE': -25.463882, 'INITIAL_LONGITUDE': 131.
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
});
}
});
}
在上面的代码中,我想给marginleftcss属性以映射。请帮助我如何给它。在第2行中,我尝试这样做,但使用该行移动贴图容器,但我要查找的是移动贴图,而不是整个容器。您可以尝试以下操作:
$("#map-canvas .gm-style").css('left', 50);
或:
但一定要把它放在最后一行,在最后一个花括号之前
这只是一个建议,因为我真的不知道你想要实现什么你考虑过在容器中添加
padding left:50px
吗?是的,但这会移动整个容器,我只查找移动地图数据。您是否试图更改地图的中心?我实际上想从左侧水平滚动它。谢谢,它对我有用。但在我的地图左边,容器地图消失意味着左边的容器看起来是空的。可以试试:$(“#地图画布”).css('margin-left',50)代码>或在屏幕截图上向我展示您试图实现的目标
$("#map-canvas .gm-style").css('margin-left', 50);