Geo_Preferences::GetMapProviderDefault PHP Method

GetMapProviderDefault() public static method

Gets the default available map provider
public static GetMapProviderDefault ( ) : string
return string
    public static function GetMapProviderDefault()
    {
        $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
        $map_prov_default = $preferencesService->MapProviderDefault;
        if (!$map_prov_default) {
            $map_prov_default = 'googlev3';
        } else {
            $map_prov_default = strtolower($map_prov_default);
        }
        $sys_pref_names = array('googlev3' => 'GoogleV3', 'osm' => 'OSM', 'mapquest' => 'MapQuest');
        $provider_available = true;
        $one_prov_usage = $preferencesService->MapProviderAvailable . ucfirst($sys_pref_names[$map_prov_default]);
        if (!$one_prov_usage) {
            $provider_available = false;
        }
        if (in_array(strtolower($one_prov_usage), array('0', 'false', 'no'))) {
            $provider_available = false;
        }
        if (!$provider_available) {
            foreach ($sys_pref_names as $one_provider => $one_prov_name) {
                $one_prov_usage = $preferencesService->MapProviderAvailable . ucfirst($sys_pref_names[$one_prov_name]);
                if (!$one_prov_usage) {
                    continue;
                }
                if (in_array(strtolower($one_prov_usage), array('0', 'false', 'no'))) {
                    continue;
                }
                $map_prov_default = $one_provider;
                $provider_available = true;
            }
        }
        if (!$provider_available) {
            $map_prov_default = 'googlev3';
        }
        return $map_prov_default;
    }

Usage Example

Example #1
0
    /**
     * Gives the header part for the map front end search by map-based rectangle selection
     * the optional p_bboxDivs array of divs for automatical setting of the box corners coordinates.
     * The bounding-box corners are available by js calls too (see e.g. locations/search.php).
     *
     * @param int $p_mapWidth
     * @param int $p_mapHeight
     * @param mixed $p_bboxDivs
     *
     * @return string
     */
    public static function GetMapSearchHeader($p_mapWidth = 0, $p_mapHeight = 0, $p_bboxDivs = null)
    {
        global $Campsite;
        $tag_string = '';
        $map_suffix = '_search';
        $cnf_html_dir = $Campsite['HTML_DIR'];
        $cnf_website_url = $Campsite['WEBSITE_URL'];
        $map_provider = Geo_Preferences::GetMapProviderDefault();
        $geo_map_info = Geo_Preferences::GetMapInfo($cnf_html_dir, $cnf_website_url, $map_provider);
        if (0 < $p_mapWidth) {
            $geo_map_info['width'] = $p_mapWidth;
        }
        if (0 < $p_mapHeight) {
            $geo_map_info['height'] = $p_mapHeight;
        }
        $geo_map_incl = Geo_Preferences::PrepareMapIncludes($geo_map_info['incl_obj']);
        $geo_map_json = '';
        $geo_map_json .= json_encode($geo_map_info['json_obj']);
        $geo_icons_info = Geo_Preferences::GetSearchInfo($cnf_html_dir, $cnf_website_url);
        $geo_icons_json = '';
        $geo_icons_json .= json_encode($geo_icons_info['json_obj']);
        $geocodingdir = $Campsite['WEBSITE_URL'] . '/js/geocoding/';
        $tag_string .= $geo_map_incl;
        $tag_string .= "\n";
        $tag_string .= '

    <script type="text/javascript" src="' . $Campsite['WEBSITE_URL'] . '/js/geocoding/map_popups.js"></script>
    <script type="text/javascript" src="' . $Campsite['WEBSITE_URL'] . '/js/geocoding/openlayers/OpenLayers.js"></script>
    <script type="text/javascript" src="' . $Campsite['WEBSITE_URL'] . '/js/geocoding/openlayers/OLlocals.js"></script>
    <script type="text/javascript" src="' . $Campsite['WEBSITE_URL'] . '/js/geocoding/map_search.js"></script>

<script type="text/javascript">

    geo_object' . $map_suffix . ' = new geo_locations();

var useSystemParameters = function()
{
';
        $tag_string .= "\n";
        $tag_string .= "geo_object{$map_suffix}.set_map_info({$geo_map_json});";
        $tag_string .= "\n";
        $tag_string .= "geo_object{$map_suffix}.set_icons_info({$geo_icons_json});";
        $tag_string .= "\n";
        if ($p_bboxDivs) {
            $bbox_divs_json = '';
            $bbox_divs_json .= json_encode($p_bboxDivs);
            $tag_string .= "geo_object{$map_suffix}.set_bbox_divs({$bbox_divs_json});";
            $tag_string .= "\n";
        }
        $tag_string .= '
};
var on_load_proc = function()
{

    var map_obj = document.getElementById ? document.getElementById("geo_map_mapcanvas' . $map_suffix . '") : null;
    if (map_obj)
    {
        map_obj.style.width = "' . $geo_map_info['width'] . 'px";
        map_obj.style.height = "' . $geo_map_info['height'] . 'px";

        geo_main_selecting_locations(geo_object' . $map_suffix . ', "' . $geocodingdir . '", "geo_map_mapcanvas' . $map_suffix . '", "map_sidedescs", "", "", true);

    }
};
    $(document).ready(function()
    {
        on_load_proc();
    });
</script>
';
        return $tag_string;
    }