欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SOSO地圖API使用(一)在地圖上畫(huà)圓實(shí)現(xiàn)思路與代碼

 更新時(shí)間:2013年01月15日 15:30:09   作者:  
最近在做SOSO地圖相關(guān)開(kāi)發(fā),遇到相關(guān)畫(huà)圓知識(shí),特此簡(jiǎn)單記錄下來(lái),接下來(lái)講解如何在在地圖上畫(huà)圓,感興趣的朋友可以了解下

前言:最近在做SOSO地圖相關(guān)開(kāi)發(fā),遇到相關(guān)畫(huà)圓知識(shí),特此簡(jiǎn)單記錄下來(lái)。
1.在頁(yè)面中添加SOSO地圖API引用,引用腳本

復(fù)制代碼 代碼如下:

<script charset="utf-8" src="http://api.map.soso.com/v1.0/main.js"></script>;

2.新建一個(gè)地圖DIV容器,如下
復(fù)制代碼 代碼如下:

<div style="width:603px;height:300px" id="container"></div>

3.初始化地圖
復(fù)制代碼 代碼如下:

 var center=new soso.maps.LatLng(22.540551,113.934593);
 var map=new soso.maps.Map(document.getElementById("container"),{
     center:center,
     zoomLevel:14
 });

4.創(chuàng)建一個(gè)圓形對(duì)象
復(fù)制代碼 代碼如下:

 var circle=new soso.maps.Circle({
        map:map,
        center:center,
        radius:1000,
        fillColor:"#00f",
        fillOpacity:0.3,
        strokeWeight:2
    });

5.為了美觀,再給圓形設(shè)置一個(gè)中心點(diǎn),代碼如下
復(fù)制代碼 代碼如下:

 var marker = new soso.maps.Marker({
     position: center,
     map: map
 });
 var anchor = new soso.maps.Point(0, 0),
     size = new soso.maps.Size(27, 35),
     icon = new soso.maps.MarkerImage('http://s.map.soso.com/themes/default/img/centermarker.png'
         , size//指定使用圖片部分的大小
         , anchor//用來(lái)指定圖標(biāo)的錨點(diǎn),默認(rèn)為圖標(biāo)中心的位置,可以指定圖標(biāo)的位置,默認(rèn)是和圖片的左上角對(duì)齊的。
         , new soso.maps.Point(0, 0)//指定使用圖片的哪一部分,相對(duì)圖片左上角的像素坐標(biāo)
         , new soso.maps.Size(27, 35)//指定圖片的原始大小
         , new soso.maps.Size(-12, -30));//向左偏12px,向上偏30px
 marker.setIcon(icon);
 var decor = new soso.maps.MarkerDecoration({
     content: '',
     margin: new soso.maps.Size(0, -4),
     align: soso.maps.ALIGN.CENTER,
     marker: marker
 });

6.完成上面的編碼后,得到一個(gè)如下圖樣子的圓形
7.具體代碼如下
復(fù)制代碼 代碼如下:

 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>SOSOMap</title>
 <style type="text/css">
 *{
     margin:0px;
     padding:0px;
 }
 body, button, input, select, textarea {
     font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
 }
 #info{
     width:603px;
     padding-top:3px;
     overflow:hidden;
 }
 .btn{
     width:190px;
 }
 </style>
 <script charset="utf-8" src="http://api.map.soso.com/v1.0/main.js"></script>
 <script type="text/javascript">
 function init(){
     var center=new soso.maps.LatLng(22.540551,113.934593);
     var map=new soso.maps.Map(document.getElementById("container"),{
         center:center,
         zoomLevel:14
     });
     var circle=new soso.maps.Circle({
         map:map,
         center:center,
         radius:1000,
         fillColor:"#00f",
         fillOpacity:0.3,
         strokeWeight:2
     });
     var marker = new soso.maps.Marker({
         position: center,
         map: map
     });
     var anchor = new soso.maps.Point(0, 0),
         size = new soso.maps.Size(27, 35),
         icon = new soso.maps.MarkerImage('http://s.map.soso.com/themes/default/img/centermarker.png'
             , size//指定使用圖片部分的大小
             , anchor//用來(lái)指定圖標(biāo)的錨點(diǎn),默認(rèn)為圖標(biāo)中心的位置
             , new soso.maps.Point(0, 0)//指定使用圖片的哪一部分,相對(duì)圖片左上角的像素坐標(biāo)
             , new soso.maps.Size(27, 35)//指定圖片的原始大小
             , new soso.maps.Size(-12, -30));//向左偏12px,向上偏30px
     marker.setIcon(icon);
     var decor = new soso.maps.MarkerDecoration({
         content: '',
         margin: new soso.maps.Size(0, -4),
         align: soso.maps.ALIGN.CENTER,
         marker: marker
     });
      var path1=[
         center
     ];
      var polyline = new soso.maps.Polyline({
         path: path1,
         strokeColor: '#000000',
         strokeWeight: 5,  
         strokeOpacity: 1,
         editable:false,
         map: map
     });
     /*
     soso.maps.Event.addListener(map,'zoomlevel_changed',function() {
         circle.setMap(null);console.log(map);
         circle.setMap(map);
     });
     */
 }
 window.onload=init;
</script>
 </head>
 <body onload="init()">
 <div style="width:603px;height:300px" id="container"></div>
 </body>
 </html>

相關(guān)文章

最新評(píng)論