google map 麻点图实现方法 源码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>map</title>

<script type="text/javascript" src="http://www.taketours.com/js/jquery/jquery-core-and-ui.js"></script>
<script type="text/javascript" src="http://ditu.google.cn/maps/api/js?sensor=false&language=zh-CN"></script>
<script type="text/javascript" src="http://www.taketours.com/js/gmap3.min.5.js"></script>
<script type="text/javascript" src="http://www.taketours.com/js/gmap3.min.5.js"></script>

<script type="text/javascript">
var map = null;
var beaches = [
	  ['Bondi Beach', -33.890542, 151.274856, 4],
	  ['Coogee Beach', -33.923036, 151.259052, 5],
	  ['Cronulla Beach', -34.028249, 151.157507, 3],
	  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
	  ['Maroubra Beach', -33.950198, 151.259302, 1]
];
var prev_infowindow =false; 
var pids = "11636;11672;37601;37605;";

function initMap(){
    var lat = "-33.9";
    var lng = "151.2";

	
    var myLatlng = new google.maps.LatLng(lat,lng);
    var myOptions = {
		zoom: 10,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		scaleControl : false,
		mapTypeControl : false,
		zoomControlOptions: {
		style: google.maps.ZoomControlStyle.BIG,
		position: google.maps.ControlPosition.LEFT_TOP
    }
    }
	
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	setMarkers(map, beaches);
	
   
}
function setMarkers(map, locations) {

  var image = {
    url: 'images/beachflag.png',
    size: new google.maps.Size(20, 32),
    origin: new google.maps.Point(0,0),
    anchor: new google.maps.Point(0, 32)

  };  

  var shape = {
      coords: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'

  };
 
  
  for (var i = 1; i < locations.length; i++) {
    var beach = locations[i];
    var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        //icon: image,
	    icon:'images/beachflag.png',
        shape: shape,
        title: beach[0],
       // zIndex: beach[3]

    });
	//Attach click event to the marker. 
   
	showinfomessage(marker, i);
 }
} 

function showinfomessage(marker,number)
{
    
    var html = $("#d" + number).html();
    var infowindow = new google.maps.InfoWindow({ 
	   content:html
     });
	 
    google.maps.event.addListener(marker, 'click', function(event) {
			if(prev_infowindow){
				prev_infowindow.close();
			}
			
			 prev_infowindow = infowindow;
			infowindow.open(map,marker);	
      });
	  
} 



</script>

</head>
<body  οnlοad="initMap()">
<div id="map_canvas" style="margin:0px; padding:0px; width:1000px; height:400px;" >

</div>

<div id="d1" style="width:185px;height:80px;text-align:left; display:none">1Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>
<div id="d2" style="width:185px;height:80px;text-align:left; display:none">2Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>
<div id="d3" style="width:185px;height:80px;text-align:left; display:none">2Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>
<div id="d4" style="width:185px;height:80px;text-align:left; display:none">3Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>
<div id="d5" style="width:185px;height:80px;text-align:left; display:none">4Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>
<div id="d6" style="width:185px;height:80px;text-align:left; display:none">5Ramada Plaza Newark Airport<br>Newark,New Jersey<br>160 Frontage Road</div>
<div style="width:100%;height:500px;"  name="n_google_map21739"></div>


</body>

</html>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值