How to render a Get Locations map programmatically? I'm using Get Locations module and the getlocations_fields submodule. I have a content type where I created a "Getlocations Fields" field, this way I can select locations when adding/editing content. I have multiple nodes which contain locations.
Now I would like to display one Get Locations map from given nodes (I have some node ids) programmatically. (I know there's Views integration, but I have a complicated task.)

What is the appropriate way to do this? I haven't found the right method yet, I don't know how Get Locations module's API works.



Hmm, maybe inspecting "A map in your own module" (https://drupal.org/node/2061951) and getlocations_fields_field_formatter_view() in getlocations_fields.module is a good start.

OK, I created a block output as per "A map in your own module". Now I need to collect the content of $latlons array. Do you know how to retrieve these data from entities with Get Locations API?

On admin/config/services/getlocations, you can configure different map markers for taxonomy terms if you "Enable Markers for Terms (Select Vocabularies enabled in a Term reference field)". I set a term reference field for my content type, and this way the NODE appears with the given marker. I would like to keep this behavior, "querying" the Get Locations field's data with markers for a given node, and display that appropriately. But I can't figure out how.
As per hutch's comment, and my experiments, I managed to solve it. I wrote it down here: https://drupal.org/node/2082137#comment-7832139.

I created a separate function for the task:

/**
 * Load a map from multiple node ids with the appropriate markers
 * 
 * @param array $nids The node ids of the nodes you want to get displayed on the map.
 * @param array $getlocations_extra_settings Some extra settings you want to override the default values with.
 * @see https:// drupal.org/node/2082137
 * @todo Patch for getlocations_setlocations() to accept settings which override the defaults, or figure out an alternative solution.
 */
function getlocations_nodemap_multiple($nids = array(), $getlocations_extra_settings = array()) {

  $latlons = array();
  $minmaxes = array('minlat' =&gt; 0, 'minlon' =&gt; 0, 'maxlat' =&gt; 0, 'maxlon' =&gt; 0);
  $count_nids = 0;
  // override default settings
  $getlocations_settings = array_merge(getlocations_defaults(), $getlocations_extra_settings);
  $marker = $getlocations_settings['node_map_marker'];
  $typemarkers = getlocations_get_markertypes('node');

  foreach ($nids as $nid) {

    // maybe a less resource consuming method should be used
    // btw., what about entity_load()? (https://api.drupal.org/api/drupal/includes!common.inc/function/entity_load/7)
    $node = node_load($nid);
    $locations = getlocations_load_locations($node-&gt;vid);

    if (isset($typemarkers[$node-&gt;type]) &amp;&amp; $typemarkers[$node-&gt;type]) {
      $marker = $typemarkers[$node-&gt;type];
    } 

    if (count($locations)) {
      // we should loop over them and dump bummers with no lat/lon
      foreach ($locations AS $key =&gt; $location) {
        $latlon = getlocations_latlon_check($location['latitude'] . ',' . $location['longitude']);
        if ($latlon) {
          $minmaxes = getlocations_do_minmaxes($count_nids, $location, $minmaxes);

          if (!isset($location['key'])) {
            $location['key'] = '';
          }
          else {
            if ($location['key'] == 'nid') {
              $location['lid'] = $nid;
            }
            elseif ($location['key'] == 'vid') {
              // not vid?
              $location['lid'] = $nid;
            }
          }

          // term markers
          $marker = getlocations_get_term_marker($nid, $marker);

          // per location marker
          if (isset($location['marker']) &amp;&amp; ! empty($location['marker'])) {
            $marker = $location['marker'];
          }

          $count_nids++;

          $name = htmlspecialchars_decode($location['name'] ? strip_tags($location['name']) : strip_tags($node-&gt;title), ENT_QUOTES);
          $latlons[] = array($location['latitude'], $location['longitude'], $location['lid'], $name, $marker, $location['key']);
        }
      }
    }
  }

  if ($count_nids &lt; 2 ) {
    $minmaxes = NULL;
  }
  return getlocations_setlocations($latlons, $minmaxes);
}


And now I can call it like this:

function testmodule_any_custom_page_callback_you_want_to_use($blabla) {

  $output = '';

  $nids_array = array(41, 45, 52, 73, 219); // of course, this array is generated

  $getlocations_extra_settings = array();
  $getlocations_extra_settings['extcontrol'] = 'testmodule';
  $getlocations_extra_settings['fullscreen'] = 1;
  $getlocations_extra_settings['streetview_show'] = 1;
  $getlocations_extra_settings['maptype'] = 'Map';
  $getlocations_extra_settings['visual_refresh'] = 1;  

  $output = getlocations_nodemap_multiple($nids_array, $getlocations_extra_settings);

  return $output;

}


This solution currently has its limitations, because unfortunately the default settings are hardcoded to getlocations_setlocations (the values of getlocations_defaults() are currently hardcoded). I hope hutch will develop this part further. :)