google地图项目总结

难点1.页面元素与地图联动的方法

//左侧公司与地图联动
   			function addcompanyEvent(data){
   				
				var company = $(".leftcon"); 
				
				for(var i=0;i<company.length;i++){
				   
					google.maps.event.addDomListener(company[i], 'click', function(){}
google.maps.event.addDomListener方法中第一个参数是document对象


难点2 地图全屏和缩小时,除了要改变map容器div的大小,还需要执行方法
           google.maps.event.trigger(map, "resize");


难点3 当需要自定义Marker时,需要导入MarkerWithLabel.js文件


var marker = new MarkerWithLabel({
	   position: point,
	   map: map,
	   labelContent: label,
	   labelAnchor: new google.maps.Point(10, 24),
	   labelClass:"labels",
	   icon:'/map/i/none.png',
	   title:countryCN[data[i].cId][1]+" : "+data[i].cCount
	});
其中labels是marker的样式,如下
.labels {
     color: #9D080D;
     background:url("/map/i/cbg.png");
     font-family: "Lucida Grande", "Arial", sans-serif;
     font-size: 12px;
     font-weight: bold;
     text-align: center;
     width: 55px;
     height: 26px;
     line-height: 18px;
     white-space: nowrap;
   }

难点4 infowindow样式的自定义(infowindow美化)


导入js文件<script type="text/javascript" src="/js/infobubble.js"></script>

定义infoBubble

var infoBubble = new InfoBubble({
               //backgroundClassName: 'mapOpen',
               shadowStyle: 3,
               padding: 0,
                content: contentString
         });

contentString是html元素

难点5 点击Marker自动隐藏上一个infowindow

     infowindows.push(infoBubble);
     markers.push(marker);
     if(lastIndex!=-1)
      {
              infowindows[lastIndex].close();
              markers[lastIndex].setAnimation(null);
       }
     marker.setAnimation(google.maps.Animation.BOUNCE);
      infoBubble.open(map, marker);      // 打开信息窗口   
      lastIndex=infowindows.indexOf(infoBubble,0);

infowindows是定义的全局变量



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值