- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码使用 mapbox 作为我的行车方向,但不幸的是它不允许我更改标记,并且即使我尝试使用 geoJson 更改它它仍然使用其默认标记
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoiZmFyc2hpZGFsYXZpIiwiYSI6ImNpZjNmNTRrYzQ0b2xzNWx1bXN5MnlmdjUifQ.IvZZfdiPe4rxQNolE88fhg';
var __journey = {"logbook":"29","consumer":"732","account":"1","category":"13","source":"2","platform":"4","vehicle":"25","label":"Farshid","startingodometer":"20000","endingodometer":"22721","note":"","status":"unverified","isreimbursable":"no","isdeductible":"yes","type":"deductible","updated":"2015-11-25 03:42:21","created":"2015-11-23 03:10:21","dbupdate":"2015-11-25 14:42:21","detail":{"logbook":"29","consumer":"732","account":"1","category":"13","source":"2","platform":"4","vehicle":"25","label":"Farshid","startingodometer":"20000","endingodometer":"22721","note":"","status":"unverified","isreimbursable":"no","isdeductible":"yes","type":"deductible","updated":"2015-11-25 03:42:21","created":"2015-11-23 03:10:21","dbupdate":"2015-11-25 14:42:21"},"__consumer":{"customer":null,"customerkey":"ed64e42a-e7c1-49b9-9fef-f5dd96bcd783","firstname":null,"lastname":null,"apikey":null,"email":"farshid@ichit.com","birth":null,"pincode":null,"pinlastupdate":null,"password":null,"gender":null,"emailverify":"1","postcode":null,"reference":null,"country":null,"forgetpasswordtoken":null,"forgetpasswordexpiry":null,"ipaddress":null,"company":"3","created":null,"updated":null,"active":"1","active !=":null,"archive":"0","archive !=":null,"mobile":null},"__account":{"id":"29","account":"Business","sequence":null,"icon":null,"parent":null,"customer":null,"admin":null,"created":"2015-11-23 03:10:21","updated":"2015-11-23 03:10:21","active":null},"__category":{"id":"29","category":"Home","brands":null,"keywords":null,"icon":null,"parent":null,"customer":null,"admin":null,"active":null,"customisable":null,"created":"2015-11-23 03:10:21","updated":"2015-11-25 03:42:21"},"__source":{"source":"29","creator":null,"name":"My Car","updated":"2015-11-25 03:42:21","created":"2015-11-23 03:10:21"},"__platform":{"platform":"29","creator":null,"name":"My Car","updated":"2015-11-25 03:42:21","created":"2015-11-23 03:10:21"},"__route":[{"logbookroute":"1448421928.896","logbook":"29","latitude":"-37.8437403","longitude":"144.9758769","pindate":"2015-11-05","pintime":"02:09 AM","journey":"29","pinned":"2015-11-05 02:09:00"},{"logbookroute":"1448421928.901","logbook":"29","latitude":"-31.980216","longitude":"115.869578","pindate":"2015-11-22","pintime":"12:10 PM","journey":"29","pinned":"2015-11-22 12:10:00"}],"__vehicle":{"vehicle":"25","consumer":"732","name":"My Car","make":"Toyota","family":"Yaris","description":"1.4 Manual","year":"2015","odometer":"20725","registrationnumber":"123ABC","isactive":"yes","isdefualt":"no","isdeleted":"no","updated":"2015-10-10 10:10:10","created":"2015-10-10 10:10:10","dbupdate":"2015-11-23 03:10:21","log":"2","__make":false,"__family":false,"__description":false},"__reimbursement":false,"taxdeduction_code":"D5","mileage":"2721","name":"My Car","accountname":"Business","categoryname":"Home","reimbursement_status":null};
var start = {lat: '-37.8437403', lng: '144.9758769'};
var finish = {lat: '-31.980216', lng: '115.869578'};
var zoom = 9;
if(Number(__journey.mileage) >= 10000) zoom = 1;
else if(Number(__journey.mileage) >= 4000) zoom = 2;
else if(Number(__journey.mileage) >= 700) zoom = 3;
else if(Number(__journey.mileage) >= 500) zoom = 5;
else if(Number(__journey.mileage) >= 400) zoom = 6;
else if(Number(__journey.mileage) >= 300) zoom = 7;
else if(Number(__journey.mileage) >= 200) zoom = 8;
else zoom = 9;
console.log(zoom);
var map = L.mapbox.map('map', 'mapbox.streets', {zoomControl: true}).setView([-35.792529592717, 129.89108613555], zoom);
var geoJson = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {
"marker-color": "#f76565",
route: {id: 1, type: "origin", points: 2}
},
geometry: {
type: "Point",
coordinates: ['144.9758769', '-37.8437403']}
},{
type: "Feature",
properties: {
"marker-color": "#f76565",
route: {id: 2, type: "destination", points: 3}
},
geometry: {
type: "Point",
coordinates: ['115.869578', '-31.980216']
}
}
]
};
var origin = {"type":"Feature","geometry":{"type":"Point","coordinates":[144.9758769,-37.8437403]},"properties":{"marker-symbol":"circle-stroked","marker-color":"ff1f20","marker-size":"medium"}};
var destination = {"type":"Feature","geometry":{"type":"Point","coordinates":[115.869578,-31.980216]},"properties":{"marker-symbol":"circle-stroked","marker-color":"23be20","marker-size":"medium"}};
// = L.mapbox.directions({profile: 'mapbox.driving'})
var directions = L.mapbox.directions();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions).addTo(map);
directions.setOrigin(origin).setDestination(destination).query();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions).addTo(map);
var myLayer = L.mapbox.featureLayer().addTo(map);
myLayer.setGeoJSON(geoJson);
最佳答案
Mapbox Directions API 将标准标记插入自定义标记之上。您似乎还多次添加了 directionsLayer
和 directionsRoutesControl
。
这应该有效:
var geoJson = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {
"marker-color": "#f76565",
"marker-symbol":"circle-stroked",
"marker-color":"ff1f20",
"marker-size": "medium",
route: {id: 1, type: "origin", points: 2}
},
geometry: {
type: "Point",
coordinates: ['144.9758769', '-37.8437403']}
},{
type: "Feature",
properties: {
"marker-color": "#f76565",
"marker-symbol":"circle-stroked",
"marker-color":"23be20",
"marker-size":"medium",
route: {id: 2, type: "destination", points: 3}
},
geometry: {
type: "Point",
coordinates: ['115.869578', '-31.980216']
}
}
]
};
var origin = geoJson.features[0];
var destination = geoJson.features[1];
var directions = L.mapbox.directions();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions).addTo(map);
directions.setOrigin(origin).setDestination(destination).query();
var myLayer = L.mapbox.featureLayer().addTo(map);
myLayer.setGeoJSON(geoJson);
这里是 a working example .
关于javascript - 带有自定义标记的 Mapbox 行车路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33909296/
我有两种类型的路由 Public 和 Private。 只有用户登录后才能访问所有私有(private)路由: return tokenService.token ? ( <>
我已按照 Laravel 5.5 文档在我们的应用程序上要求、安装和配置 Laravel Passport。我们仅使用密码授予功能,因为我们不打算将其用作社交登录工具。但是,按照所有说明操作后,我在尝
我想设置事件菜单项的样式,为此我需要将当前 url 与路由进行比较。我知道我可以在 javascript 中做到这一点,但我想知道其他人是如何解决这个问题的。 有什么建议么? 伪代码: My Page
我正在尝试在浏览器上以图形方式显示路径/路线以供客户查看。例如,基于 txt 或 XML 文件,包含说明。 4 90 5 90 2 或 F4,L90,F5,L90,F2 相当于
我创建了一个中间件来阻止我的 laravel 应用程序中的某些路由,但不起作用,无法弄清楚我做错了什么,这是我的代码: ps:我使用的是 laravel 5.2 路线: Route::get('sec
我正在使用 Java 工作。给定一个矩阵 NxM,我需要找到通过该数组的所有可能路径。只允许斜向上或斜向下,或向右斜行。 4x4 矩阵示例: 3 5 7 9 2 4 6 8 9 3 7
我是 Marionette 新手,只是找不到上类路线。 我正在使用 Marionette 的 2.4.1 版本,并尝试以最简单的方式进行操作,以便它能够正常工作。 此代码适用于旧版本的 Marione
我是 AngularJS 的新手。我正在尝试从这个网站( https://docs.angularjs.org/tutorial/step_07 )学习 AngularJS。我的代码如下 index.
我在 yandexmapkit-android 项目上工作。图书馆链接是 https://github.com/yandexmobile/yandexmapkit-android 文档非常薄弱,git
我正在阅读有关 Angular 路由的文档并创建了一个简单的测试: const routes: Route[] = [ { path: '', redirectTo: '/home', pat
我正在开发一项服务 (spring-boot),它获取一个 ID 列表,一个一个地从数据库中获取对象,将这些对象聚合成批处理,然后将它们保存在其他地方。目前,聚合后的批量大小约为 50 个对象,大约每
我正在制作一个网站,在用户登录后,用户将被重定向到主页。网站的主页和所有其他页面只能由登录用户访问,但即使在用户登录后(firebase auth),网站的其余部分( protected 路由)仍然无
我有一个惰性模块,我希望在桌面和移动设备上有不同的体验。基本上我想要我的桌面布局如下: Component1 显示一个列表,用户在列表中选择一个项目,component2 将显示详细信息。我创建了名为
我是 Angular 的新手,我正在尝试让我的路由器工作。基本上我在 / 有一个主页,其中有一个到 /courses 的路由器链接,它运行良好,但是当我重新加载 /courses 时(或输入地址in)
完整的 Mojolicious 应用程序有 routes将转储应用程序路由的命令: script/my_app.pl routes 我如何从 Lite 的测试脚本中做同样的事情应用? use Mojo
我有一个 Camel 2.13.1 应用程序,它使用我通过 CXF 组件访问的外部 Web 服务。我使用 Spring XML 路由元素的 startupOrder 属性来确保在我设置为在启动时调用一
我们有一个在 Karaf 2.4.3 和 Camel 2.15.3 上运行的数据处理应用程序。 在这个应用程序中,我们有一堆导入数据的路由。我们有一个管理 View ,其中列出了这些路由以及每条路由的
我正在尝试组合一个应用程序,我可以在其中查询谷歌路线服务,存储结果以建立缓存,然后根据需要呈现路线。 我可以取回方向数据并将其存储在数据库中就好了,这一切都很好,现在当我在 map 上渲染方向时,我的
我根据 Ryan Bates 的 railscast 使用设计登录创建了一个新项目. 它没有注册路线(与我之前制作的项目不同,步骤完全相同) This image显示了两个“rake 路由”命令。顶
我发现 Google Maps API 通过以下方式支持路线: var map; var directionsPanel; var directions; function initialize()
我是一名优秀的程序员,十分优秀!