我正在建设的程序,显示许多人的位置。如何设置中心,使其显示所有位置?
这是我的代码,但我需要缩小以查看其他位置
gMaps = new GoogleMaps();
map = gMaps.createMap(getWidth(), getHeight(), GoogleStaticMap.FORMAT_PNG);
map.setHandler(this);
map.setCenter(new GoogleMapsCoordinates(24.71167 ,46.72417));发布于 2011-11-02 16:41:20
这可以通过使用fitBounds()方法来实现。查看Google Maps v3 API reference。
小示例:
//set viewport
var viewport = new google.maps.LatLngBounds();
viewport.extend(p1);
viewport.extend(p2);
//center map using active markers
map.fitBounds(viewport);在该示例中,p1和p2是坐标(后面是lng)。
https://stackoverflow.com/questions/7977472
复制相似问题