Пример #1
0
$props['bounds'] = $modx->getOption('bounds', $scriptProperties, $modx->getOption('gmarker.bounds'));
$props['components'] = $modx->getOption('components', $scriptProperties, $modx->getOption('gmarker.components'));
$props['region'] = $modx->getOption('region', $scriptProperties, $modx->getOption('gmarker.region'));
$props['language'] = $modx->getOption('language', $scriptProperties, $modx->getOption('gmarker.language'));
// Other props that are used in the output
$props2 = array();
$props2['h'] = (int) $modx->getOption('height', $scriptProperties, $modx->getOption('gmarker.default_height'));
$props2['w'] = (int) $modx->getOption('width', $scriptProperties, $modx->getOption('gmarker.default_width'));
$props2['id'] = $modx->getOption('id', $scriptProperties, 'map');
$props2['zoom'] = $modx->getOption('zoom', $scriptProperties, 15);
$props2['type'] = $modx->getOption('type', $scriptProperties, 'ROADMAP');
$props2['gmarker_url'] = $Gmarker->get_maps_url(array('key' => $modx->getOption('gmarker.apikey')), $secure);
// Verify inputs
if (empty($address) && empty($latlng) && empty($components)) {
    $modx->log(xPDO::LOG_LEVEL_ERROR, '[Gmap] ' . $modx->lexicon('missing_params'));
    return $Gmarker->alert($modx->lexicon('missing_params'));
}
if (!$props2['h']) {
    $props2['h'] = 300;
}
if (!$props2['w']) {
    $props2['w'] = 500;
}
// Handle lookups and caching
// Fingerprint the lookup
$json = $Gmarker->lookup($props);
// Pull the coordinates out
$props2['lat'] = number_format($Gmarker->get('location.lat'), 8);
$props2['lng'] = number_format($Gmarker->get('location.lng'), 8);
// Add the stuff to the head
$modx->regClientStartupHTMLBlock($modx->getChunk($headTpl, $props2));