javascript - 将方形或圆形图像放入谷歌地图中的直线路径中

标签 javascript google-maps line

我使用 javascript 和 GPS 坐标在 Google map 中绘制了一条线路路径。

谁能告诉我如何在 Google map 中绘制的直线路径的末尾放置一个圆形或正方形。

DEMO

我的代码如下所示

function initialize(){
       var center= new google.maps.LatLng(10.012552,76.327043);
       var myOptions = {
                zoom: 16,
                center: center,
                mapTypeControl: true,
                mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
                navigationControl: true,
                mapTypeId: google.maps.MapTypeId.ROADMAP
       }     
      var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

      var polylineCoordinates = [
            new google.maps.LatLng(10.013566,76.331549),
            new google.maps.LatLng(10.013566,76.331463),
            new google.maps.LatLng(10.013503,76.331313),
            new google.maps.LatLng(10.013482,76.331205),
            new google.maps.LatLng(10.013419,76.330926),
new google.maps.LatLng(10.013334,76.330712),
new google.maps.LatLng(10.013313,76.330411),
new google.maps.LatLng(10.013292,76.330175),
new google.maps.LatLng(10.013228,76.329854),
new google.maps.LatLng(10.013144,76.329553),
new google.maps.LatLng(10.013059,76.329296),
new google.maps.LatLng(10.012996,76.329017),
new google.maps.LatLng(10.012869,76.328802),
new google.maps.LatLng(10.012785,76.328545),
new google.maps.LatLng(10.012700,76.328223),
new google.maps.LatLng(10.012679,76.328030),
new google.maps.LatLng(10.012658,76.327837),
new google.maps.LatLng(10.012637,76.327600),
new google.maps.LatLng(10.012573,76.327322),
new google.maps.LatLng(10.012552,76.327043),

      ];
      var polyline = new google.maps.Polyline({
          path: polylineCoordinates,
          strokeColor: '#FF3300',
          strokeOpacity: 2.0,
          strokeWeight: 5,
          editable: false
      });

      polyline.setMap(map);    
}
initialize();

最佳答案

您可以创建一个Icon在给定位置polylineCoordinates[polylineCoordinates.length-1]

http://jsfiddle.net/wLeBh/5/

关于javascript - 将方形或圆形图像放入谷歌地图中的直线路径中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15541257/

相关文章:

javascript - 尝试将 js 字符串转换为 NSDateFormatter

javascript - ASP.Net jQuery AJAX 调用不起作用

swift - 快速标记数组的自定义 infoView

javascript - 谷歌地图 infowindow 错误 f = undefined infowindow.js

javascript - Google map API V3 英国地区

用于代码语法突出显示的 JavaScript 库,然后在 HTML 中在行级别进行差异?

javascript - jQuery:循环迭代编号类?

JavaScript 挑战 : Loops - Multiple Conditions - stuck and can't figure this out

wpf - 水平虚线拉伸(stretch)至容器宽度

c - 从文件中删除包含输入单词的行