|
本帖最后由 大象课堂 于 2018-10-26 10:22 编辑
官网给的演示例子,说得不够清楚,加上这个ID就好使了。贴上代码
- var map = api.require('bMap');
- map.open({
- rect: {
- x: 0,
- y: 0,
- w: 'auto',
- h: 300
- },
- center: {
- lon: 116.4021310000,
- lat: 39.9994480000
- },
- zoomLevel: 10,
- showUserLocation: true,
- fixedOn: api.frameName,
- fixed: true
- }, function (ret) {
- if (ret.status) {
- map.searchRoute({
- id: 1,
- type: 'drive',
- policy: 'ecar_fee_first',
- start: {
- lon: 116.403838,
- lat: 39.914437
- },
- end: {
- lon: 116.384852,
- lat: 39.989576
- }
- }, function (ret, err) {
- if (ret.status) {
- map.drawRoute({
- id: 1,
- autoresizing: true,
- index: 0,
- styles: {
- start: {
- icon: 'widget://image/location.png'
- },
- end: {
- icon: 'widget://image/location.png'
- }
- }
- }, function (ret) {
- api.alert({ msg: JSON.stringify(ret) });
- });
- } else {
- api.alert({ msg: JSON.stringify(err) });
- }
- });
- }
- });
复制代码 题图两张,问题终结者。若解决你问题,给个赞!
|
|