Google Maps Api:将地图的中心设置为像素偏移量? [英] Google Maps Api: set center of the map to an offset in pixels?

查看:102
本文介绍了Google Maps Api:将地图的中心设置为像素偏移量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个奇怪的问题...

我使用Google Maps API在我的网页上嵌入自定义地图。我将 lon / lat 坐标传递给一个函数,并在这个中间绘制了一个以这个居中为中心的地图。 (我的地图框架像300px高,所以标记大约150px)

由于我也使用自定义 infoWindows / Boxes

code>我想将地图的中心向下移动一下。



我知道我可以在中设置一个单独的中心, lon / lat 坐标,但这不是我要找的。这将需要每个地图通过标记的坐标和我想要的中心坐标。



我希望它更多简单。



是否可以将地图的中心向下移动几个像素?



center:+ 30px,:)

  var latlng = new google.maps .LatLng(ll [0],ll [1]); //经度和纬度
var options = {
zoom:zoom,
// center:c,
mapTypeId:google.maps.MapTypeId.ROADMAP,
mapTypeControl :false,
disableDefaultUI:true,
scrollwheel:scroll,
streetViewControl:false,
navigationControlOptions:{
style:google.maps.NavigationControlStyle.SMALL
}
}

任何想法我能做到吗?任何奥特技巧或想法?

解决方案

调用地图的panBy方法

  mapObject.panBy(0,30)


this might be a weird question …

I'm using the google maps api to embed custom maps on my webpage. I pass the lon/lat coordinates along to a function and a map is drawn with this point "centered" in the middle. (my map frame is like 300px high, so the marker is approx at 150px)

Since I'm also using custom infoWindows/Boxes I'd like to move the center of the map a bit down.

I know I could set a seperate center in lon/lat coordinates but that's not what I'm looking for. This would require for every map to pass along the coordinates of the marker and the coordinates of the center I'd like to have.

I'd like it to be more simple.

Is it possible to move the center of the map just a few pixels down?

Like center: +30px, :)

var latlng = new google.maps.LatLng(ll[0], ll[1]); // latitude and longitude
    var options = {
    zoom: zoom,
    //center: c,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false,
    disableDefaultUI: true,
    scrollwheel: scroll,
    streetViewControl: false,
    navigationControlOptions: {  
        style: google.maps.NavigationControlStyle.SMALL 
    }
}

Any idea how I could do that? Any oder tricks or ideas?

解决方案

call the panBy-method of the map

mapObject.panBy(0,30)

这篇关于Google Maps Api:将地图的中心设置为像素偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆