WEB开发网
开发学院网页设计JavaScript google map api 与jquery结合使用(3) --图标样式... 阅读

google map api 与jquery结合使用(3) --图标样式,使用xml和异步请求

 2010-09-14 13:29:39 来源:WEB开发网   
核心提示:创建图标map.js$(document).ready(function(){ if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map"));map.addControl(new GSmallMap

创建图标

map.js

$(document).ready(function()
{
   if (GBrowserIsCompatible()) {
     var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(36.94,106.08),4);
    //创建小图标
    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);
    //随机的添加10个标记
    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));
    }
    $(window).unload(function (){
        $('.').unbind();
        GUnload();
      });
   }else
   {
     alert('你使用的浏览器不支持 Google Map!');  
   }
});

1 2 3  下一页

Tags:google map api

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接