Javascript,将地址字符串传递给 MapQuest API 不工作
Javascript, passing string of addresses to MapQuest API NOT working
我正在将地址列表动态传递给字符串变量,并希望使用 MapQuest API 在地图上绘制它们。但是,当我将这些地址传递给我的函数时,出现错误。
mq-routing.js?key=jP…M0C6qxa2BKpuAhqZ:44 Uncaught TypeError: Cannot read property 'length' of undefined
at e.route (mq-routing.js?key=jP…M0C6qxa2BKpuAhqZ:44)
at map.cfm:153
它似乎不喜欢我传递地址字符串的方式。
'<script type="text/javascript" language="JavaScript">
var jsmyRouteStops="{locations: ['100 W Atlantic Blvd Pompano Beach FL, 33060-6099','50 W Atlantic Blvd, BL Pompano Beach FL, 33060-6002','111 N Pompano Beach Blvd, BL Pompano Beach FL, 33062-5703','201 N Ocean Blvd, BL Pompano Beach FL, 33062-5104','501 N Riverside Dr Pompano Beach FL, 33062-4702','2809 NW 2nd St Pompano Beach FL, 33069-2523','3095 N Course Dr Pompano Beach FL, 33069-3300','2600 S Course Dr Pompano Beach FL, 33069-3900','[1401 - 1477] SW 26th Ave Pompano Beach FL, 33069-4315','705 Gardens Dr Pompano Beach FL, 33069-0945']}"; new Array();
var map,
dir;
map = L.map('map', {
layers: MQ.mapLayer(),
center: [ 26.230735, -80.124932 ],
zoom: 15
});
dir = MQ.routing.directions();
dir.route(jsmyRouteStops.trim());
map.addLayer(MQ.routing.routeLayer({
directions: dir,
fitBounds: true
}));
</script>
这里有什么我应该做的不同的吗?
dir.route(jsmyRouteStops.trim());
非常感谢任何帮助,谢谢!!!
当我删除 jsmyRouteStops 周围的引号时,它对我有用。
var jsmyRouteStops={locations: ['100 W Atlantic Blvd Pompano Beach FL, 33060-6099','50 W Atlantic Blvd, BL Pompano Beach FL, 33060-6002','111 N Pompano Beach Blvd, BL Pompano Beach FL, 33062-5703','201 N Ocean Blvd, BL Pompano Beach FL, 33062-5104','501 N Riverside Dr Pompano Beach FL, 33062-4702','2809 NW 2nd St Pompano Beach FL, 33069- 2523','3095 N Course Dr Pompano Beach FL, 33069-3300','2600 S Course Dr Pompano Beach FL, 33069-3900','[1401 - 1477] SW 26th Ave Pompano Beach FL, 33069-4315',' 705 Gardens Dr Pompano Beach FL, 33069-0945']};
我正在将地址列表动态传递给字符串变量,并希望使用 MapQuest API 在地图上绘制它们。但是,当我将这些地址传递给我的函数时,出现错误。
mq-routing.js?key=jP…M0C6qxa2BKpuAhqZ:44 Uncaught TypeError: Cannot read property 'length' of undefined
at e.route (mq-routing.js?key=jP…M0C6qxa2BKpuAhqZ:44)
at map.cfm:153
它似乎不喜欢我传递地址字符串的方式。
'<script type="text/javascript" language="JavaScript">
var jsmyRouteStops="{locations: ['100 W Atlantic Blvd Pompano Beach FL, 33060-6099','50 W Atlantic Blvd, BL Pompano Beach FL, 33060-6002','111 N Pompano Beach Blvd, BL Pompano Beach FL, 33062-5703','201 N Ocean Blvd, BL Pompano Beach FL, 33062-5104','501 N Riverside Dr Pompano Beach FL, 33062-4702','2809 NW 2nd St Pompano Beach FL, 33069-2523','3095 N Course Dr Pompano Beach FL, 33069-3300','2600 S Course Dr Pompano Beach FL, 33069-3900','[1401 - 1477] SW 26th Ave Pompano Beach FL, 33069-4315','705 Gardens Dr Pompano Beach FL, 33069-0945']}"; new Array();
var map,
dir;
map = L.map('map', {
layers: MQ.mapLayer(),
center: [ 26.230735, -80.124932 ],
zoom: 15
});
dir = MQ.routing.directions();
dir.route(jsmyRouteStops.trim());
map.addLayer(MQ.routing.routeLayer({
directions: dir,
fitBounds: true
}));
</script>
这里有什么我应该做的不同的吗?
dir.route(jsmyRouteStops.trim());
非常感谢任何帮助,谢谢!!!
当我删除 jsmyRouteStops 周围的引号时,它对我有用。
var jsmyRouteStops={locations: ['100 W Atlantic Blvd Pompano Beach FL, 33060-6099','50 W Atlantic Blvd, BL Pompano Beach FL, 33060-6002','111 N Pompano Beach Blvd, BL Pompano Beach FL, 33062-5703','201 N Ocean Blvd, BL Pompano Beach FL, 33062-5104','501 N Riverside Dr Pompano Beach FL, 33062-4702','2809 NW 2nd St Pompano Beach FL, 33069- 2523','3095 N Course Dr Pompano Beach FL, 33069-3300','2600 S Course Dr Pompano Beach FL, 33069-3900','[1401 - 1477] SW 26th Ave Pompano Beach FL, 33069-4315',' 705 Gardens Dr Pompano Beach FL, 33069-0945']};