Hi
Return is used in javascript for two reasons.
You want the script to stop executing if something happens.
You want the function to return a value to the calling function.
Try
var newVar;
var heading =
google.maps.geometry.spherical.computeHeading(path[0],path[1]);
if (heading>0)
newVar = Math.round(heading);
else
newVar = Math.round(360-heading);
Or just use heading instead of newVar if appropriate
ie
var heading =
google.maps.geometry.spherical.computeHeading(path[0],path[1]);
if (heading>0)
heading = Math.round(heading);
else
heading = Math.round(360-heading);
Regards Davie
On Jan 8, 3:14 pm, HansW <[email protected]> wrote:
> Hi,
>
> I am trying to make a if then for a google map heading to return 0 to
> 360 degrees, I am reading my first book on this subject and am not
> proficient yet.
>
> Something goes wrong obviously, however I do not understand why:
>
> var heading = google.maps.geometry.spherical.computeHeading(path[0],
> path[1]); if (heading>0) return Math.round(heading);
> else if (heading<=0) return Math.round(360-heading);
> return heading;
>
> Thanks for any replies.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.