简体   繁体   English

如何在 azure 地图中添加双向线

[英]how can i add Bi directional lines in azure maps

is there any way we can add two polylines between two coordinates new atlas.data.LineString([[point A],[point B]]) new atlas.data.LineString([[point B],[point A]]) like this currently it shows only one line when i add this to data source有什么方法可以在两个坐标之间添加两条折线 new atlas.data.LineString([[point A],[point B]]) new atlas.data.LineString([[point B],[point A]])像这样,当我将它添加到数据源时它只显示一行

if it is just the Polyline you want to plot between points and indicate with two different colors, you can use the offset property of LineLayerOptions and plot the lines using the following JavaScript.如果它只是你想要在点之间 plot 并用两个不同的 colors 表示的折线,你可以使用 LineLayerOptions 的偏移属性和plot使用以下 JavaScript 的线。

  var dataSource = new atlas.source.DataSource();
  map.sources.add(dataSource);

  //Create a line and add it to the data source.
  dataSource.add(new atlas.data.LineString([[-73.972340, 40.743270], [-74.004420, 40.756800]]));

  //Create a line layer to render the line to the map.
  map.layers.add(new atlas.layer.LineLayer(dataSource, null, {
    strokeColor: 'green',
    strokeWidth: 1,
    offset: -2
  })); 
  
  map.layers.add(new atlas.layer.LineLayer(dataSource, null, {
    strokeColor: 'red',
    strokeWidth: 1,
    offset: 2
  })); 
});

The above JavaScript would produce the following Ploy Lines on Azure Maps.上述 JavaScript 将在 Azure 地图上产生以下策略线。

在此处输入图像描述

Optionally, you can add a distinct data source if you prefer and map the layers for each data source.或者,您可以根据需要添加不同的数据源,并为每个数据源添加 map 层。 But you can achieve the same output by using a single data source as indicated above.但是您可以通过使用上面指示的单个数据源来实现相同的 output。

I have built the JavaScript code based on the Azure Maps documentation Add Line Layer to the Map where you can find great code references to add symbols and line gradients.我已经根据 Azure 地图文档构建了 JavaScript 代码将线图层添加到 Map ,您可以在其中找到用于添加符号和线渐变的出色代码参考。 Here is the link to the LineLayers interface which provides a list of options that you can use when rendering line layers in Azure Map.这是LineLayers界面的链接,它提供了一个选项列表,您可以在 Azure Map 中渲染线层时使用这些选项。

If you have one linestring and you want a second linestring with coordinates in the opposite order, you can create a deep copy of the linestring, and then reverse the coordinate array, then add the lines to the data source.如果您有一个线串并且想要第二个坐标顺序相反的线串,您可以创建线串的深层副本,然后反转坐标数组,然后将线添加到数据源。 For example, if you have a GeoJSON linestring object:例如,如果您有一个 GeoJSON 线串 object:

var line = new atlas.data.LineString([[-73.972340, 40.743270], [-74.004420, 40.756800]]);

//Create a deep copy of the line.
var newLine  = JSON.parse(JSON.stringify(line));

//Reverse the order of the coordinates in the new line.
newLine.coordinates.reverse();

As you noted, these lines will overlap when rendered.如您所述,这些线在渲染时会重叠。 What you can do to add a visual separation, turn one of these into a GeoJSON feature and add a unique property that can be seen by the data driven styles, then use the offset option of the LineLayer .您可以做些什么来添加视觉分隔,将其中一个变成 GeoJSON 功能并添加一个唯一的属性,该属性可以被数据驱动 styles 看到,然后使用LineLayer的偏移选项。 For example:例如:

//Create a feature from the line and add some property we can use to know this is a reverse copy of a line when styling.
var newFeature = new atlas.data.Feature(newLine, { isCopy: true });

//Add the feature to the data source instead of the new line.
datasource.add(newFeature);

//Have two-line layers with a filter 

//Line layer for original lines.
map.layers.add(new atlas.layer.LineLayer(dataSource, null, {
    strokeColor: 'green',
    strokeWidth: 1,
    offset: -2,
    filter: ['!', ['has', 'isCopy']]
})); 

//A second line layer that renders the line copies
map.layers.add(new atlas.layer.LineLayer(dataSource, null, {
    strokeColor: 'red',
    strokeWidth: 1,
    offset: 2,
    filter: ['has', 'isCopy']
})); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在 Power BI 中利用 Azure 认知搜索吗? - Can I Leverage Azure cognitive search with/inside power BI? 如何将文件添加到 Azurite [Azure 存储模拟器] - How Can I add a file to Azurite [Azure Storage Emulator] 如何在 azure function 绑定文件中的变量值中添加正则表达式? - How can I add regex in a variable value in azure function bindings file? 如何删除 Azure 中的通用虚拟机? - How can I delete a generalized VM in Azure? 如何在谷歌地图 flutter 中动态绘制多边形? - How can I dynamically draw polygons in google maps flutter? 如何将最后刷新日期可视化添加到我的 PowerBI 报告中,显示 Azure Analysis Services 中数据 model 的最后刷新时间 - How can I add a last refreshed date visual to my PowerBI report showing the last refreshed time of a data model in Azure Analysis Services 我可以使用 Terraform 将 azure 功能添加到 DPS 吗? - Can I add azure functions to a DPS using Terraform? 如何在 Azure DevOps 上运行的 PowerShell 上登录 azure - How can I login azure on PowerShell that run on Azure DevOps 如何将 Terraform 中的逻辑用于 Azure? - How can i use logic in Terraform for Azure? 如何授权保护Azure Function? - How I can protect Azure Function by authorization?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM