I am working on a project and I think I am stuck on this. I have a form that I want to add points to a map as users edit it.
Here's a rundown on how the form works:
The user chooses a number (1-10) for how many stops they'd like to make from a select list. The select list defaults to 1 and below it there is a select list that lists all of the points of interest they can choose from. If they change the first select to 2 the ajax callback updates the form and adds an additional select box of POIs. That's working great.
What I'd like to be able to do is add the POI to a map on the page whenever they select it (with driving directions between them). I have an ajax callback on the POI select list in order to do this but I am having trouble figuring out where to go from here.
I have the following in my POI callback (for testing) and it works, but I am having trouble figuring out what ajax_command_ function to use to call a js function to add the point to the map.
$commands = array();
$commands = ajax_command_alert("Here!");
return array('#type' => 'ajax', '#commands' => $commands);
Basically I just need to pass the latitude and longitude of the POI (which I am gathering in the callback) and send it to a js function to then update the map. My first thought was using drupal_add_js but I couldn't get it working and discovered later that it was not the right way to go.