预览文章: 初学 Google Maps JavaScript (5) 画圆指定范围

:lol:
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no;">
<meta charset="utf-8" />
<script src="http://maps.google.com/maps/api/js?sensor=false&language=zh"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<style>#map{width:100%;height:100%}.info{font-size:14px}</style>
<script>
var latlng=marker=circle=geocoder=infowindow=map=address=null;
$.LatLng = function(lat,lng){
return new google.maps.LatLng(lat,lng);
}
$.Marker = function(opts){
return new google.maps.Marker(opts);
}
$.InfoWindow = function(opts){
return new google.maps.InfoWindow(opts);
}
$.Circle = function(opts){
return new google.maps.Circle(opts);
}
$.Geocoder = function(){
return new google.maps.Geocoder();
}
$(function(){
$.getJSON('gLatlng.php',{jz:'基站信息'},function(d){
latlng = $.LatLng(d.lat,d.lng)
map = new google.maps.Map($('#map')[0],{
zoom:8,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
});
marker=$.Marker({position:latlng,map:map,icon:"1.png",draggable:true});
circle=$.Circle({
strokeColor: "#86ACDE",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#DCE2EA",
fillOpacity: 0.7,
map: map,
center: latlng,
radius: 35000
});
infowindow = $.InfoWindow();
geocoder = $.Geocoder();
geocoder.geocode({'latLng':latlng},function(results,status){
if(geocoder){
if(status==google.maps.GeocoderStatus.OK){
infowindow.setContent('<span class="info">'+results[0].formatted_address+'</span>');
}
else{
alert(status);
}
}
});
infowindow.open(map,marker);
google.maps.event.addListener(marker,"click",function(){
infowindow.open(map,marker);
});
google.maps.event
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值