function getlocations_typemap in Get Locations 6
Same name and namespace in other branches
- 6.2 getlocations.module \getlocations_typemap()
- 7 getlocations.module \getlocations_typemap()
Menu callback
Parameters
string $type: A location enabled content type
Return value
Returns a map of locations of all nodes of content-type $type
1 call to getlocations_typemap()
1 string reference to 'getlocations_typemap'
- getlocations_menu in ./
getlocations.module - Implementation of hook_menu().
File
- ./
getlocations.module, line 376 - Displays locations on a map. for Drupal 6 using version 3 googlemaps API
Code
function getlocations_typemap($type, $loc_key = '', $loc_val = '') {
$getlocations_defaults = getlocations_defaults();
$marker = $getlocations_defaults['node_map_marker'];
$typemarkers = getlocations_get_markertypes('node');
if (isset($typemarkers[$type]) && $typemarkers[$type]) {
$marker = $typemarkers[$type];
}
$latlons = array();
$minmaxes = array(
'minlat' => 0,
'minlon' => 0,
'maxlat' => 0,
'maxlon' => 0,
);
$result = db_query("SELECT nid, title FROM {node} WHERE type='%s'", array(
$type,
));
$ct = 0;
while ($row = db_fetch_object($result)) {
$nid = $row->nid;
$vid = getlocations_get_vid($nid);
$locations = getlocations_load_locations($vid);
if (count($locations)) {
// we should loop over them and dump bummers with no lat/lon
foreach ($locations as $key => $location) {
if (getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
if ($loc_key && isset($location[$loc_key])) {
if (drupal_strtolower($location[$loc_key]) != drupal_strtolower($loc_val)) {
continue;
}
}
$minmaxes = getlocations_do_minmaxes($ct, $location, $minmaxes);
if (!isset($location['key'])) {
$location['key'] = '';
}
else {
if ($location['key'] == 'nid') {
$location['lid'] = $nid;
}
elseif ($location['key'] == 'vid') {
$location['lid'] = $vid;
}
}
// per location marker
if (isset($location['marker']) && !empty($location['marker'])) {
$marker = $location['marker'];
}
$ct++;
$name = htmlspecialchars_decode($location['name'] ? strip_tags($location['name']) : strip_tags($row->title), ENT_QUOTES);
$latlons[] = array(
$location['latitude'],
$location['longitude'],
$location['lid'],
$name,
$marker,
$location['key'],
);
}
}
}
}
if ($ct < 2) {
unset($minmaxes);
$minmaxes = '';
}
return getlocations_setlocations($latlons, $minmaxes, $type);
}