请问如何在Google maps 上添加标注?
初用Google maps 很多问题不明白,期待高人指教:
1.如何在Google maps上添加标注?
1.我现在网页上的Google maps有切换地图控件,但网页打开的时候默认的是道路地图而不是卫星地图,请问如何使网页打开的时候默认用的是卫星地图或混合地图
3.Google maps有没有这样的功能,根据城市名自动定位到城市,比如:从数据库中取出城市名,然后在网页打开的时候自动把地图中心点定位在北京市?
问的有点多... 我刚刚学Google maps 什么都不懂,希望大家赐教,谢谢!
[解决办法]
1.var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
// Create our "tiny" marker icon
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(point, icon));
}
效果:http://www.google.com/apis/maps/documentation/icon.html
2.map.setMapType(G_HYBRID_MAP);
3.map.setCenter(new GLatLng(37.4419, -122.1419), 13);
(参考:http://www.codechina.org/doc/google/gmapapi/#Introduction)
[解决办法]
官方论坛有例子,楼主可以参考下,