标记图标上获取方向谷歌地图

时间:2014-11-14 11:56:03

标签: google-maps

我有一个关于在谷歌地图上放置标记获取路线的问题。我有这个脚本,在页面加载渲染地图但是,我想在这张地图上放置公司徽标。我的意思是像没有任何指示的初始地图。

    src="https://maps.googleapis.com/maps/api/js?v=3&amp;sensor=false"></script><script type="text/javascript">// <![CDATA[
var map;
        var directionsDisplay;
        var manila = new google.maps.LatLng(55.009657,-1.450706);
        var directionsService = new google.maps.DirectionsService(); 
        function initialize() {
            // Make the route draggable
            var rendererOptions = {
                draggable: true,                   
            } 
            directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
            var mapOptions = {
                zoom:13,
                mapTypeId: google.maps.MapTypeId.DRIVING,
                center: manila,
            }

            map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
            directionsDisplay.setMap(map);
            directionsDisplay.setPanel(document.getElementById("directionsPanel"));

        }

我知道为了在地图上有图标,你需要创建标记对象......

var marker=new google.maps.Marker({
  position:manila,
  icon:'image-link'
  });

并使用此标记设置map:

marker.setMap(map);

但我使用directionsDisplay.setMap(map);代替marker.setMap(map);我如何将此marker对象传递给directionsService地图?

1 个答案:

答案 0 :(得分:0)

相关问题