I am working on pset8, and I am trying to implement pickup(). I have to find out if any of the passengers in PASSENGERS are closer than fifteen meters away. I currently have this if statement:

if (shuttle.distance(markers[i].position.latitude,markers[i].position.longitude)<15) {

but it does not seem to work. I believe I am not using markers.position correctly, but I am not sure.

(NOTE: markers is an array of all the markers, which corresponds to the array of the passengers.)


Does your markers array include placemarks?

If so, try using markers[i].placemark.getGeometry().getLatitude(); (and ...getLongitude()) to get your lat and lon.

  • Would you need to use some type of for each loop to check the position of each passenger in PASSENGERS relative to the shuttle? This is the logic that I was thinking, but I'm having trouble understanding for each loops in javascript. – Daniel Levi Dec 8 '14 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .