Set current location in a route based on a arbitrary distance - here-api

I'm just playing around with Here and this is my escenario for an idea.
Get a routing between 2 points, I know this is doable
Set the start and finish marker, I know this is doable
Get the distance between the 2 points, I know this is doable
Now, if the distance from point 1 and 2 is 3000 meters I want to set a marker ( You are here ) based on a arbitrary distance value, let say I want to add a marker at the 1750 meters point, the market should appears in the half route way.
Is this posible with the actual API?
Thanks in advance!

Yes it is possible to do with HERE javascript API.
Once you get routing response and create H.geo.LineString out of it, you can calculate distance between each two geo points from that line string using H.geo.Point#distance method. This will help to determine between which two points (lat, lng) is your desired arbitrary distance.
After that you need to calculate angle between these two geo points and use it in method H.geo.Point#walk in order to get exact position of the geo point you need.
Here you can find jsfiddle example which places marker on the simple LineString based on desired arbitrary distance.

Related

is there a way to set heading for a Point?

I have heading that i get with this computeHeading(from:LatLng, to:LatLng), latlng of one point and distance to second point(in meters) is there a way using these three things to get latlng of second point ?
From google docs Navigation Functions
Given a particular heading, an origin location, and the distance to travel (in meters), you can calculate the destination coordinates using computeOffset().

Google Maps API v3 Polylines not drawing

App works this way:
User enters a starting location and a distance. User can choose to draw circles, or lines over the roads. Circles work fine. Lines used to work.
When Lines, the code finds the lat/long of the starting location, then for the points N, S, E, W of the origin at the distance set by the user (say, 100km). Starting with the N destination, the code calls google.maps.DirectionsService() to get directions from the origin to N. This returns an array of lat/longs in the the route.overview_path.
NOTE: I COULD use the directionsRenderer() to draw the route, BUT, the distance drawn would be greater than the distance set by the user. Drawing the entire route from the origin to the point N might be 124km over the roads, and I just want to draw 100km.
Instead, I step through the route.overview_path[] array, checking the distance between that point and the point of origin, adding each point to a new array. When the distance is greater than the dist set by the user, I stop, pop off the last element, then create a new Polyline based on this 2nd, smaller array.
I've spent the entire day in Chrome's developer mode walking through the javascript, setting breakpoints, watching locals, etc. The array of points passed in google.maps.Polyline({}) is a good array of unique points. I just cannot figure out why they aren't rendering.
Ultimately, the code used to draw 4 lines starting at the point of origin, one heading North, one heading East, South, West. etc....
The code is here: http://whosquick.com/RunViz.html
Thank you for your attention.
Nevermind. Solved it.
var objGeo = new LatLon(Geo.parseDMS(myroute.overview_path[0].Pa), Geo.parseDMS(myroute.overview_path[0].Qa));
I had inadvertently switched Pa with Qa.

Vector to closest isosurface point on metaballs

I'm currently making a prototype game where the player walks along the isosurface of a collection of moving metaballs. I've already implemented walking along a sphere with a forward and up vector. To extend this to the metaballs I need to be able to query for an arbitrary point the direction to the closest surface and the distance to the closest surface to be able to snap the player back to the surface after I've moved him along the forward vector. I can calculate the direction by taking a weighted average of all vectors but how do I get the distance?
I'm using the 1 / (x*x + y*y + z*z) function with an isosurface of 1 for my metaballs but I would appreciate any generalization so that I can use the same approach for other shapes.
In general, you would just derive your function to get the normal on the surface. Blackpawn has a nice explanation how to do it with your specific case here.
Once you got the normal, move along its direction until you hit the isosurface (this is generic "root" finding).

How to get coordinates of a point on a polyline by meters?

I loop along an MVCArray ... trying to split the segments by an offset.
But I would require a little more precision to split the poly-line at the proper points.
Basically I just would need to know how to calculate a point on a line between 2 points - defined by the last few meters.
Or is there any way to insert a verticle at this position?
Talking of Maps API V3.

Google Maps API: colouring locations

Apologies if this is dead simple..
I can see that it's possible to draw on an area using overlays, but is it possible to just draw(colour) a location (a pair of longitude and latitude coordinates)?
I need to colour a map by specifying a colour for every location I have available in my database.
I'm also a bit concerned about the speed.
Any ideas/advice welcome!
Thanks
A lat/lon pair represents a point, and a point has zero size. You cannot color something that has no size, therefore you need to represent those points with something bigger than a point, like a marker or a polygon, both of which are overlays.

Resources