1

I am stuck on trying to remove the placemarks after picking up a passenger. The problem is that I can keep adding the same passenger even though the placemark has been visually removed. I need help with this! Here is the code with some console.logs() thrown in. I can't figure out why the code Zamyla gave isn't removing the placemarks.

                for(var j = 0, numberadded = 0; j < shuttle.seats.length && numberadded == 0; j++)
                {
                    // check for empty seats
                    if (shuttle.seats[j] == null)
                    {
                        // if empty, allow the current passenger to board
                        shuttle.seats[j] = PASSENGERS[i];
                        numberadded = 1;
                        seatsleft -= 1;
                        
                        console.log(PASSENGERS[i]);
                        
                        // remove placemark and marker
                        earth.getFeatures().removeChild(PASSENGERS[i].placemark);
                        PASSENGERS[i].marker.setMap(null);
                        
                        console.log(PASSENGERS[i]);
                        console.log(PASSENGERS[i].placemark);
                    }
                    
                }
                // update chart
                chart();
                console.log(shuttle.seats[1].placemark);

debugging information is here

Object {username: "dhu", name: "Dianna Hu", house: "Quincy House", marker: On, placemark: Object}
service.js:320 Object {username: "dhu", name: "Dianna Hu", house: "Quincy House", marker: On, placemark: Object}
service.js:321 Object {}
service.js:327 Uncaught TypeError: Cannot read property 'placemark' of null
1
  • I am having a similar problem, the person is gone from all the maps, but if you keep hitting pickup they get on the bus again. – aharris Dec 21 '14 at 13:50
0

Consider checking for the actual presence of the passenger on the list before accepting him/her aboard...

You must log in to answer this question.

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