本文整理汇总了PHP中CRM_Contact_BAO_Contact_Location::getMapInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Location::getMapInfo方法的具体用法?PHP CRM_Contact_BAO_Contact_Location::getMapInfo怎么用?PHP CRM_Contact_BAO_Contact_Location::getMapInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact_Location
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact_Location::getMapInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* This function is called when action is browse
*
* return null
* @access public
*/
function browse()
{
// get the primary city, state and zip for the contact
$ids = array($this->_contactId);
$locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids);
$rows =& CRM_Utils_Sunlight::getInfo($locations[0]['city'], $locations[0]['state'], $locations[0]['postal_code']);
$this->assign('rowCount', count($rows));
$this->assign_by_ref('rows', $rows);
}
示例2: createMapXML
/**
* Assign smarty variables to the template that will be used by google api to plot the contacts.
*
* @param array $ids
* @param int $locationId
* Location_id.
* @param CRM_Core_Page $page
* @param bool $addBreadCrumb
* @param string $type
*/
public static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact')
{
$config = CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(ts('Map Location(s)'));
$page->assign('query', 'CiviCRM Search Query');
$page->assign('mapProvider', $config->mapProvider);
$page->assign('mapKey', urlencode($config->mapAPIKey));
if ($type == 'Contact') {
$imageUrlOnly = FALSE;
// google needs image url, CRM-6564
if ($config->mapProvider == 'Google' || $config->mapProvider == 'OpenStreetMaps') {
$imageUrlOnly = TRUE;
}
$locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids, $locationId, $imageUrlOnly);
} else {
$locations = CRM_Event_BAO_Event::getMapInfo($ids);
}
if (empty($locations)) {
CRM_Core_Error::statusBounce(ts('This address does not contain latitude/longitude information and cannot be mapped.'));
}
if (empty($config->mapProvider)) {
CRM_Core_Error::statusBounce(ts('You need to configure a Mapping Provider before using this feature (Administer > System Settings > Mapping and Geocoding).'));
}
if ($addBreadCrumb) {
$session = CRM_Core_Session::singleton();
$redirect = $session->readUserContext();
if ($type == 'Contact') {
$bcTitle = ts('Contact');
} else {
$bcTitle = ts('Event Info');
$action = CRM_Utils_Request::retrieve('action', 'String', $page, FALSE);
if ($action) {
$args = 'reset=1&action=preview&id=';
} else {
$args = 'reset=1&id=';
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/event/info', "{$args}{$ids}"));
}
CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
}
$page->assign_by_ref('locations', $locations);
// only issue a javascript warning if we know we will not
// mess the poor user with too many warnings
if (count($locations) <= 3) {
$page->assign('geoCodeWarn', TRUE);
} else {
$page->assign('geoCodeWarn', FALSE);
}
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = 400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$page->assign_by_ref('center', $center);
$page->assign_by_ref('span', $span);
}
示例3: createMapXML
/**
* assign smarty variables to the template that will be used by google api to plot the contacts
*
* @param array $contactIds list of contact ids that we need to plot
* @param int $locationId location_id
*
* @return string the location of the file we have created
* @access protected
*/
static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact')
{
$config =& CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(ts('Map Location(s)'));
$page->assign('query', 'CiviCRM Search Query');
$page->assign('mapProvider', $config->mapProvider);
$page->assign('mapKey', $config->mapAPIKey);
if ($type == 'Contact') {
require_once 'CRM/Contact/BAO/Contact/Location.php';
$locations =& CRM_Contact_BAO_Contact_Location::getMapInfo($ids, $locationId);
} else {
require_once 'CRM/Event/BAO/Event.php';
$locations =& CRM_Event_BAO_Event::getMapInfo($ids);
}
if (empty($locations)) {
CRM_Core_Error::statusBounce(ts('This address does not contain latitude/longitude information and cannot be mapped.'));
}
if ($addBreadCrumb) {
$session =& CRM_Core_Session::singleton();
$redirect = $session->readUserContext();
if ($type == 'Contact') {
$bcTitle = ts('Contact');
} else {
$bcTitle = ts('Event Info');
$action = CRM_Utils_Request::retrieve('action', 'String', $page, false);
if ($action) {
$args = 'reset=1&action=preview&id=';
} else {
$args = 'reset=1&id=';
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/event/info', "{$args}{$ids}"));
}
CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
}
$page->assign_by_ref('locations', $locations);
// only issue a javascript warning if we know we will not
// mess the poor user with too many warnings
if (count($locations) <= 3) {
$page->assign('geoCodeWarn', true);
} else {
$page->assign('geoCodeWarn', false);
}
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$page->assign_by_ref('center', $center);
$page->assign_by_ref('span', $span);
}