0

我正在尝试创建一个路线规划器来跟踪我的跑步路线。使用 Bing 地图,我可以创建路线,但我很难删除默认的“开始”、“结束”和“红圈”行程图标。

以下是我到目前为止的代码(基于此链接)。我基本上想要的只是路线开头的开始图标和结尾的结束图标。除了路线之外,我不需要其他任何东西。

任何帮助(以及代码改进提示)都非常感谢!

 jQuery(function() {

    GetMap();

    $("#btnStartRoute").click(function() {
      map.AttachEvent('onclick', StartRouting);
    });
  });

  var map = null;
  var myRoute = [];
  var noOfPushPins = 0;

  function GetMap() {
    map = new VEMap('mapContent');
    map.SetCredentials("xxxxxxxxxxxxxxxxxx");
    map.LoadMap();
  }

  function StartRouting(e) {
    var xPoint = e.mapX, yPoint = e.mapY;
    var pixel = new VEPixel(xPoint, yPoint);
    var LL = map.PixelToLatLong(pixel);
    cornerOne = LL; //cornerOne is a global level var
    var latitude = map.PixelToLatLong(pixel).Latitude;
    var longitiude = map.PixelToLatLong(pixel).Longitude;
    myRoute[noOfPushPins] = new VELatLong(latitude, longitiude);
    noOfPushPins++;
    GetRoute();
  }

  function GetRoute() {
    var myRouteOptions = new VERouteOptions();
    myRouteOptions.RouteMode = VERouteMode.Walking;
    myRouteOptions.RouteColor = new VEColor(0, 102, 51, .7);
    myRouteOptions.RouteCallback = RouteCallback;
    map.GetDirections(myRoute, myRouteOptions);
  }

  function RouteCallback(route) {
    var myRouteShapes = [];
    var myRoutePoints = [];
    var points = route.RouteLegs[0].Itinerary.Items;
    $.each(points, function(i) {
      var routePointCoordinates = new VELatLong(route.RouteLegs[0].Itinerary.Items[i].LatLong.Latitude, route.RouteLegs[0].Itinerary.Items[i].LatLong.Longitude);
      var routePointShape = new VEShape(VEShapeType.Pushpin, routePointCoordinates);
      if (i != 0) {
        routePointShape.SetCustomIcon("<img id='pushPin" + noOfPushPins + "' class='pushPin' src='/Content/Images/Maps/pushPinEnd.gif'><span class='pushPinText'>" + (noOfPushPins + 1) + "</span>");

      } else {
        routePointShape.SetCustomIcon("<img id='pushPin" + noOfPushPins + "' class='pushPin' src='/Content/Images/Maps/pushPinStart.gif'><span class='pushPinText'>" + (noOfPushPins + 1) + "</span>");
      }
      myRoutePoints.push(routePointShape);
      map.Clear();
      map.DeleteRoute();
      map.AddShape(myRoutePoints);
    });
  }
4

1 回答 1

0

Itinerary 对象上有一个名为“Shape”的未记录属性。你可以隐藏它......更多信息在这里:http ://social.msdn.microsoft.com/Forums/en/vemapcontroldev/thread/430449d0-fde4-4adb-9132-248fa6f9db65

于 2010-06-14T16:24:33.017 回答