Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

Here Maps Javascript API - Malformed Request when trying to dynamically add multiple waypoints

So I have an MVC webapp that aims to search a vehicle by its plate, return a large string with latitude and longitude coordinates from my database showing where it's been through, and then draw a route on a map with every set of 'lat,long' as a waypoint. I know that if I input every coordinate manually it works, but what I'm trying to do, since every plate is going to return a different set of coordinates, is assigning an array to routingParameters' via, using H.service.Url.MultiValueQueryParameter().

I have an array named slice, which displays the following:

["'-23.502750,-46.845710'", "'-23.502750,-46.845710'", "'-23.502655,-46.845567'", "'-23.502655,-46.845567'", "'-23.502655,-46.845567'", "'-23.506386,-46.838802'...]"

I then assign it to via as such:

'via': new H.service.Url.MultiValueQueryParameter(slice)

and Here Maps API returns the following error:

{"title":"Malformed request","status":400,"code":"E605001","cause":"Error while parsing request: 

Invalid location specification at ''-23.502750,-46.845710''
Invalid waypoint at ''-23.502750,-46.845710''
Unexpected input at ''-23.502750,-46.845710''
Invalid value for parameter 'via' at ''-23.502750,-46.845710''","action":"","correlationId":"e01765c2-9db1-465c-87bd-ab9b1e9cc444"}

Is there any way this can be done?

question from:https://stackoverflow.com/questions/66065304/here-maps-javascript-api-malformed-request-when-trying-to-dynamically-add-mult

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The following waypoint values should have only one pair of double or single quotes:

["'-23.502750,-46.845710'", "'-23.502750,-46.845710'", "'-23.502655,-46.845567'", "'-23.502655,-46.845567'", "'-23.502655,-46.845567'", "'-23.506386,-46.838802'...]"

for example

["-23.502750,-46.845710", "-23.502750,-46.845710", "-23.502655,-46.845567", "-23.502655,-46.845567", "-23.502655,-46.845567", "-23.506386,-46.838802"...]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...