protected function _checkValidCenter()
 {
     $center = geolocation_get_center();
     $centerLat = $center['latitude'];
     $centerLng = $center['longitude'];
     $centerZoomLevel = $center['zoomLevel'];
     $this->assertTrue(is_double($centerLat));
     $this->assertTrue(is_double($centerLng));
     $this->assertTrue(is_double($centerZoomLevel));
     $this->assertEquals(get_option('geolocation_default_latitude'), $centerLat);
     $this->assertEquals(get_option('geolocation_default_longitude'), $centerLng);
     $this->assertEquals(get_option('geolocation_default_zoom_level'), $centerZoomLevel);
 }
예제 #2
0
/**
 * Returns the form code for geographically searching for items
 * @param Item $item
 * @param int $width
 * @param int $height
 * @return string
 **/
function geolocation_map_form($item, $width = '100%', $height = '410px', $label = 'Find a Location by Address:', $confirmLocationChange = true, $post = null)
{
    $ht = '';
    $center = geolocation_get_center();
    $center['show'] = false;
    $location = geolocation_get_location_for_item($item, true);
    if ($post === null) {
        $post = $_POST;
    }
    $usePost = !empty($post) && !empty($post['geolocation']);
    if ($usePost) {
        $lng = (double) @$post['geolocation']['longitude'];
        $lat = (double) @$post['geolocation']['latitude'];
        $zoom = (int) @$post['geolocation']['zoom_level'];
        $addr = @$post['geolocation']['address'];
    } else {
        if ($location) {
            $lng = (double) $location['longitude'];
            $lat = (double) $location['latitude'];
            $zoom = (int) $location['zoom_level'];
            $addr = $location['address'];
        } else {
            $lng = $lat = $zoom = $addr = '';
        }
    }
    ob_start();
    ?>
<div id="location_form">
    <input type="hidden" name="geolocation[latitude]" value="<?php 
    echo $lat;
    ?>
" />
    <input type="hidden" name="geolocation[longitude]" value="<?php 
    echo $lng;
    ?>
" />
    <input type="hidden" name="geolocation[zoom_level]" value="<?php 
    echo $zoom;
    ?>
" />
    <input type="hidden" name="geolocation[map_type]" value="Google Maps v<?php 
    echo GOOGLE_MAPS_API_VERSION;
    ?>
" />
    <label style="display:inline; float:none; vertical-align:baseline;"><?php 
    echo html_escape($label);
    ?>
</label>
    <input type="text" name="geolocation[address]" id="geolocation_address" size="60" value="<?php 
    echo $addr;
    ?>
" class="textinput"/>
    <button type="button" style="margin-bottom: 18px; float:none;" name="geolocation_find_location_by_address" id="geolocation_find_location_by_address">Find</button>
</div>
<?php 
    $options = array();
    $options['form'] = array('id' => 'location_form', 'posted' => $usePost);
    if ($location or $usePost) {
        $options['point'] = array('latitude' => $lat, 'longitude' => $lng, 'zoomLevel' => $zoom);
    }
    $options['confirmLocationChange'] = $confirmLocationChange;
    $center = js_escape($center);
    $options = js_escape($options);
    $divId = 'omeka-map-form';
    ?>
    <div id="<?php 
    echo html_escape($divId);
    ?>
" style="width: <?php 
    echo $width;
    ?>
; height: <?php 
    echo $height;
    ?>
;"></div>
    <script type="text/javascript">
        //<![CDATA[
        var anOmekaMapForm = new OmekaMapForm(<?php 
    echo js_escape($divId);
    ?>
, <?php 
    echo $center;
    ?>
, <?php 
    echo $options;
    ?>
);
        jQuery(document).bind('omeka:tabselected', function () {
            anOmekaMapForm.resize();
        });
        //]]>
    </script>
<?php 
    $ht .= ob_get_contents();
    ob_end_clean();
    return $ht;
}