I have an issue to find a routing service for each user in here map
i'm using here map to find a Route of multiple users and destination.
I type new york in search bar and hit search button, let suppose api return array of ten users. Now i want to get routing service for each users.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
}
Now when i run this code platform.getRoutingService is run 10 times before giving me result of each user.
here is my complete for loop code.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
console.log(parameters);
//debugger;
router.calculateRoute(parameters,
function (result) {
}
}
javascript maps here-maps-rest
add a comment |
i'm using here map to find a Route of multiple users and destination.
I type new york in search bar and hit search button, let suppose api return array of ten users. Now i want to get routing service for each users.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
}
Now when i run this code platform.getRoutingService is run 10 times before giving me result of each user.
here is my complete for loop code.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
console.log(parameters);
//debugger;
router.calculateRoute(parameters,
function (result) {
}
}
javascript maps here-maps-rest
add a comment |
i'm using here map to find a Route of multiple users and destination.
I type new york in search bar and hit search button, let suppose api return array of ten users. Now i want to get routing service for each users.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
}
Now when i run this code platform.getRoutingService is run 10 times before giving me result of each user.
here is my complete for loop code.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
console.log(parameters);
//debugger;
router.calculateRoute(parameters,
function (result) {
}
}
javascript maps here-maps-rest
i'm using here map to find a Route of multiple users and destination.
I type new york in search bar and hit search button, let suppose api return array of ten users. Now i want to get routing service for each users.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
}
Now when i run this code platform.getRoutingService is run 10 times before giving me result of each user.
here is my complete for loop code.
for(var i=0; i< aws_data.length; i++)
{
aws_possition =
{
lat: aws_data[i].lat,
lng: aws_data[i].lng
};
lat2 = aws_possition.lat;
lng2 = aws_possition.lng;
var router = platform.getRoutingService(),
parameters = {
waypoint0: lat1+","+lng1,
waypoint1: lat2+","+lng2,
mode: 'fastest;car;traffic:enabled',
departure: 'now'
};
console.log(parameters);
//debugger;
router.calculateRoute(parameters,
function (result) {
}
}
javascript maps here-maps-rest
javascript maps here-maps-rest
asked Nov 13 '18 at 14:53
Farrukh SultanFarrukh Sultan
112
112
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Hello Farrakh and welcome to Stack Overflow. If you are using this API then you can map your data to promises (note that promises need to be polifilled for IE and (very) old browsers)
const router = platform.getRoutingService(),
waypoint1 = aws_possition.lat + ',' + aws_possition.lng,
mode = 'fastest;car;traffic:enabled',
departure = 'now';
Promise.all(
aws_data.map(
({ lat, lng, id }) =>
console.log(`processing ${id}`) ||
new Promise((resolve, reject) =>
router.calculateRoute(
{
waypoint0: lat + ',' + lng,
waypoint1,
mode,
departure,
},
(result)=>resolve([id,result]),
reject,
),
),
),
).then(
(results) => console.log('I have results:', results),
(error) => console.log('something went wrong:', error),
);
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can tryplatform.getRoutingService().calculateRoute(
instead ofrouter.calculateRoute(
– HMR
Nov 15 '18 at 7:36
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283695%2fi-have-an-issue-to-find-a-routing-service-for-each-user-in-here-map%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hello Farrakh and welcome to Stack Overflow. If you are using this API then you can map your data to promises (note that promises need to be polifilled for IE and (very) old browsers)
const router = platform.getRoutingService(),
waypoint1 = aws_possition.lat + ',' + aws_possition.lng,
mode = 'fastest;car;traffic:enabled',
departure = 'now';
Promise.all(
aws_data.map(
({ lat, lng, id }) =>
console.log(`processing ${id}`) ||
new Promise((resolve, reject) =>
router.calculateRoute(
{
waypoint0: lat + ',' + lng,
waypoint1,
mode,
departure,
},
(result)=>resolve([id,result]),
reject,
),
),
),
).then(
(results) => console.log('I have results:', results),
(error) => console.log('something went wrong:', error),
);
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can tryplatform.getRoutingService().calculateRoute(
instead ofrouter.calculateRoute(
– HMR
Nov 15 '18 at 7:36
|
show 1 more comment
Hello Farrakh and welcome to Stack Overflow. If you are using this API then you can map your data to promises (note that promises need to be polifilled for IE and (very) old browsers)
const router = platform.getRoutingService(),
waypoint1 = aws_possition.lat + ',' + aws_possition.lng,
mode = 'fastest;car;traffic:enabled',
departure = 'now';
Promise.all(
aws_data.map(
({ lat, lng, id }) =>
console.log(`processing ${id}`) ||
new Promise((resolve, reject) =>
router.calculateRoute(
{
waypoint0: lat + ',' + lng,
waypoint1,
mode,
departure,
},
(result)=>resolve([id,result]),
reject,
),
),
),
).then(
(results) => console.log('I have results:', results),
(error) => console.log('something went wrong:', error),
);
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can tryplatform.getRoutingService().calculateRoute(
instead ofrouter.calculateRoute(
– HMR
Nov 15 '18 at 7:36
|
show 1 more comment
Hello Farrakh and welcome to Stack Overflow. If you are using this API then you can map your data to promises (note that promises need to be polifilled for IE and (very) old browsers)
const router = platform.getRoutingService(),
waypoint1 = aws_possition.lat + ',' + aws_possition.lng,
mode = 'fastest;car;traffic:enabled',
departure = 'now';
Promise.all(
aws_data.map(
({ lat, lng, id }) =>
console.log(`processing ${id}`) ||
new Promise((resolve, reject) =>
router.calculateRoute(
{
waypoint0: lat + ',' + lng,
waypoint1,
mode,
departure,
},
(result)=>resolve([id,result]),
reject,
),
),
),
).then(
(results) => console.log('I have results:', results),
(error) => console.log('something went wrong:', error),
);
Hello Farrakh and welcome to Stack Overflow. If you are using this API then you can map your data to promises (note that promises need to be polifilled for IE and (very) old browsers)
const router = platform.getRoutingService(),
waypoint1 = aws_possition.lat + ',' + aws_possition.lng,
mode = 'fastest;car;traffic:enabled',
departure = 'now';
Promise.all(
aws_data.map(
({ lat, lng, id }) =>
console.log(`processing ${id}`) ||
new Promise((resolve, reject) =>
router.calculateRoute(
{
waypoint0: lat + ',' + lng,
waypoint1,
mode,
departure,
},
(result)=>resolve([id,result]),
reject,
),
),
),
).then(
(results) => console.log('I have results:', results),
(error) => console.log('something went wrong:', error),
);
edited Nov 14 '18 at 11:19
answered Nov 13 '18 at 15:19
HMRHMR
13.7k113898
13.7k113898
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can tryplatform.getRoutingService().calculateRoute(
instead ofrouter.calculateRoute(
– HMR
Nov 15 '18 at 7:36
|
show 1 more comment
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can tryplatform.getRoutingService().calculateRoute(
instead ofrouter.calculateRoute(
– HMR
Nov 15 '18 at 7:36
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
No its not working as i want and in results it disturb the sequence also. this is my array data {lat: 44.9887974188151, lng: -122.972739162038, id: "+15108629326", updatedDateInMillis: 1542083089077} I have to show the result against this id but even in result it changes the original latitude and longitude but in different ways.
– Farrukh Sultan
Nov 14 '18 at 9:01
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
The only way i left is to compare latitude and longitude but because of changing i'm unable to do this. Please help me
– Farrukh Sultan
Nov 14 '18 at 9:02
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
@FarrukhSultan I have added the id to the result. If you don't get any errors then it should log the results, what is wrong with the results?
– HMR
Nov 14 '18 at 11:19
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
I'm getting output in repeated data and these repeated data i'm getting 10 times I have results: (10) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
– Farrukh Sultan
Nov 14 '18 at 18:18
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can try
platform.getRoutingService().calculateRoute(
instead of router.calculateRoute(
– HMR
Nov 15 '18 at 7:36
@FarrukhSultan You can see the values of the array when you click on it. It should have a different id and route result for each value. if the route result is the same for each one then you can try
platform.getRoutingService().calculateRoute(
instead of router.calculateRoute(
– HMR
Nov 15 '18 at 7:36
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283695%2fi-have-an-issue-to-find-a-routing-service-for-each-user-in-here-map%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown