另一个关于如何删除版本 2 中的 A 和 B 图标的 Google 地图问题。*

发布于 2024-10-21 22:01:38 字数 4016 浏览 1 评论 0原文

我对这个主题进行了大量研究,但没有取得多大成功。我必须指出,我是谷歌地图和 javascript 的真正初学者。 我试图删除询问方向时出现在谷歌地图上的 A 和 B 图标。

我正在为一个很棒的教程中的方向创建自定义布局,但我正在努力从地图本身中删除 A 和 B 符号。 当我把头撞到砖墙上时,任何帮助将不胜感激。

代码

 if (GBrowserIsCompatible()) {

  var map = new GMap2(document.getElementById("map"));
  var dirn = new GDirections(map);
//var dirn = new GDirections(map).setOptions( { suppressMarkers: true } );


  GEvent.addListener(dirn,"error", function() {
    alert("Directions Failed: "+dirn.getStatus().code);
  });

 dirn.load("from: <% Response.Write homlat %>,<% Response.Write homlng %> to: "+Slat+","+Slongtit+"", {getSteps:true});


  function customPanel(map,mapname,dirn,div) {
    var html = "";



    function waypoint(point, type, address) {
      var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
      html += '<table style="border: 3px solid silver; margin: 10px 0px; background-color: rgb(238, 238, 238); border-collapse: collapse; color: rgb(0, 0, 0);">';
      html += '  <tr style="cursor: pointer;" onclick='+target+'>';
      html += '    <td style="padding: 4px 15px 0px 5px; vertical-align: middle; width: 20px;">';



     html += '      <img src="http://www.google.com/intl/en_ALL/mapfiles/icon-dd-' +type+ '-trans.png">'
      html +=       type;
      html += '    <\/td>';
      html += '    <td style="vertical-align: middle; width: 100%;">';
      html +=        address;
      html += '    <\/td>';
      html += '  <\/tr>';
      html += '<\/table>';
    }


    function routeDistance(dist) {
      html += '<div style="text-align: right; padding-bottom: 0.3em;">' + dist + '<\/div>';
    }      

    function detail(point, num, description, dist) {
      var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
      html += '<table style="margin: 0px; padding: 0px; border-collapse: collapse;">';
      html += '  <tr style="cursor: pointer;" onclick='+target+'>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px; vertical-align: top; text-align: right;">';
      html += '      <a href="javascript:void(0)"> '+num+'. <\/a>';
      html += '    <\/td>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px; vertical-align: top; width: 100%;">';
      html +=        description;
      html += '    <\/td>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px 0.3em 0.5em; vertical-align: top; text-align: right;">';
      html +=        dist;
      html += '    <\/td>';
      html += '  <\/tr>';
      html += '<\/table>';
    }

    function copyright(text) {
      html += '<div style="font-size: 0.86em;">' + text + "<\/div>";
    }


    for (var i=0; i<dirn.getNumRoutes(); i++) {
      if (i==0) {
       // var type="play";
      var type="<img src='map_images/man_image.png'>";
      } else {
        var type="pause";
      }
      var route = dirn.getRoute(i);
      var geocode = route.getStartGeocode();
      var point = route.getStep(0).getLatLng();


     waypoint(point, type, addsrch);
    routeDistance(route.getDistance().html+" (about "+route.getDuration().html+")"); 

      for (var j=0; j<route.getNumSteps(); j++) {
        var step = route.getStep(j);
        detail(step.getLatLng(), j+1, step.getDescriptionHtml(), step.getDistance().html);
      }
    }

    var geocode = route.getEndGeocode();
    var point = route.getEndLatLng();
  waypoint(point, stopIcons[Sicon], Sbuild);
    copyright(dirn.getCopyrightsHtml());


    div.innerHTML = html;

  }
GEvent.addListener(dirn,"load", function() {
    setTimeout('customPanel(map,"map",dirn,document.getElementById("path"))', 1);
  });

}

目前我正在使用 Google 地图 API 版本 2.* 的 。非常感谢任何提供帮助的人。

I have done vast research on this topic without much success. I must point out that I am a real beginner of google maps and javascript.
I am trying to remove the A and B icons that appear on google map when asking for directions.

I am in creating a customised layout for the directions from a great tutorial but I am struggling in removing the A and B symbol from the map itself.
Any help will be apprecaited as I am banging my head against a brick wall.

The Code currently

 if (GBrowserIsCompatible()) {

  var map = new GMap2(document.getElementById("map"));
  var dirn = new GDirections(map);
//var dirn = new GDirections(map).setOptions( { suppressMarkers: true } );


  GEvent.addListener(dirn,"error", function() {
    alert("Directions Failed: "+dirn.getStatus().code);
  });

 dirn.load("from: <% Response.Write homlat %>,<% Response.Write homlng %> to: "+Slat+","+Slongtit+"", {getSteps:true});


  function customPanel(map,mapname,dirn,div) {
    var html = "";



    function waypoint(point, type, address) {
      var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
      html += '<table style="border: 3px solid silver; margin: 10px 0px; background-color: rgb(238, 238, 238); border-collapse: collapse; color: rgb(0, 0, 0);">';
      html += '  <tr style="cursor: pointer;" onclick='+target+'>';
      html += '    <td style="padding: 4px 15px 0px 5px; vertical-align: middle; width: 20px;">';



     html += '      <img src="http://www.google.com/intl/en_ALL/mapfiles/icon-dd-' +type+ '-trans.png">'
      html +=       type;
      html += '    <\/td>';
      html += '    <td style="vertical-align: middle; width: 100%;">';
      html +=        address;
      html += '    <\/td>';
      html += '  <\/tr>';
      html += '<\/table>';
    }


    function routeDistance(dist) {
      html += '<div style="text-align: right; padding-bottom: 0.3em;">' + dist + '<\/div>';
    }      

    function detail(point, num, description, dist) {
      var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
      html += '<table style="margin: 0px; padding: 0px; border-collapse: collapse;">';
      html += '  <tr style="cursor: pointer;" onclick='+target+'>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px; vertical-align: top; text-align: right;">';
      html += '      <a href="javascript:void(0)"> '+num+'. <\/a>';
      html += '    <\/td>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px; vertical-align: top; width: 100%;">';
      html +=        description;
      html += '    <\/td>';
      html += '    <td style="border-top: 1px solid rgb(205, 205, 205); margin: 0px; padding: 0.3em 3px 0.3em 0.5em; vertical-align: top; text-align: right;">';
      html +=        dist;
      html += '    <\/td>';
      html += '  <\/tr>';
      html += '<\/table>';
    }

    function copyright(text) {
      html += '<div style="font-size: 0.86em;">' + text + "<\/div>";
    }


    for (var i=0; i<dirn.getNumRoutes(); i++) {
      if (i==0) {
       // var type="play";
      var type="<img src='map_images/man_image.png'>";
      } else {
        var type="pause";
      }
      var route = dirn.getRoute(i);
      var geocode = route.getStartGeocode();
      var point = route.getStep(0).getLatLng();


     waypoint(point, type, addsrch);
    routeDistance(route.getDistance().html+" (about "+route.getDuration().html+")"); 

      for (var j=0; j<route.getNumSteps(); j++) {
        var step = route.getStep(j);
        detail(step.getLatLng(), j+1, step.getDescriptionHtml(), step.getDistance().html);
      }
    }

    var geocode = route.getEndGeocode();
    var point = route.getEndLatLng();
  waypoint(point, stopIcons[Sicon], Sbuild);
    copyright(dirn.getCopyrightsHtml());


    div.innerHTML = html;

  }
GEvent.addListener(dirn,"load", function() {
    setTimeout('customPanel(map,"map",dirn,document.getElementById("path"))', 1);
  });

}

I am using Google maps API ver 2.*. Many Thanks for anyone who helps.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜血缘 2024-10-28 22:01:38

在这种情况下,您无法直接访问标记,因为它们是在生成路线时自动生成的。
您必须使用名为 DirectionsRenderer 的特定函数来抑制它们


//existing code
var map = new GMap2(document.getElementById("map"));
var dirn = new GDirections(map);

//additional code
var directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.suppressMarkers = true;

You don't have direct access to the markers in this case because they are automatically generated when directions are generated.
You have to suppress them with a specific function called DirectionsRenderer


//existing code
var map = new GMap2(document.getElementById("map"));
var dirn = new GDirections(map);

//additional code
var directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.suppressMarkers = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文