地图 web

1. 使用自己原创的标记图标:
var map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(), 13);

var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "blue.png";                 
// Set up our GMarkerOptions object
markerOptions = { icon:blueIcon };
map.addOverlay(new GMarker(map.getCenter(), markerOptions));

2.自定义控件,将google默认的放大缩小图标换成自己的图标。还是利用google API来实现,map.zoomIn()实现地图放大,map.zoomOut()实现地图缩小。
function ImgZoomControl() {}
  
ImgZoomControl.prototype = new GControl();
ImgZoomControl.prototype.initialize = function(map) {
    var container = document.createElement("div");
//container.id = "container";
var img_zoomin = document.createElement("img");
img_zoomin.id ="zoomin1";
img_zoomin.src = "images/zoomin2.png";
img_zoomin.onclick = function(){ map.zoomIn();}
var img_zoomout = document.createElement("img");
img_zoomout.id ="zoomout1";
img_zoomout.src = "images/zoomout2.png";
img_zoomout.onclick = function(){ map.zoomOut();}
container.appendChild(img_zoomin);
container.appendChild(img_zoomout);
    map.getContainer().appendChild(container);
return container;
    }

    ImgZoomControl.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
    }



你可能感兴趣的:(Web,Google,prototype,UP)