Back to PhocaGalleryRenderMaposm class

Method setMapType

public
setMapType
()

Method setMapType - Source code

function setMapType()
{
    $app = Factory::getApplication();
    // Possible new parameters
    $thunderForestMapType = $this->thunderforestmaptype;
    $thunderForestKey = $this->maprouterapikey;
    $mapBoxKey = $this->maprouterapikey;
    $type = $this->osmmaptype;
    $o = array();
    if ($type === "osm_de") {
        $o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png\', {';
        $o[] = '	maxZoom: 18,';
        $o[] = '	attribution: \'© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
        $o[] = '}).addTo(map' . $this->name . $this->id . ');';
    } else {
        if ($type === "osm_bw") {
            //$o[] = 'L.tileLayer(\'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png\', {';
            $o[] = 'L.tileLayer(\'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png\', {';
            $o[] = '	maxZoom: 18,';
            $o[] = '	attribution: \'© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
            $o[] = '}).addTo(map' . $this->name . $this->id . ');';
        } else {
            if ($type === 'thunderforest') {
                if ($thunderForestKey == '') {
                    $app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_API_KEY_NOT_SET'));
                    return false;
                }
                if ($thunderForestMapType == '') {
                    $app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_MAP_TYPE_NOT_SET'));
                    return false;
                }
                $o[] = 'L.tileLayer(\'https://{s}.tile.thunderforest.com/' . PhocaGalleryText::filterValue($thunderForestMapType, 'url') . '/{z}/{x}/{y}.png?apikey={apikey}\', {';
                $o[] = '	maxZoom: 22,';
                $o[] = '	apikey: ' . PhocaGalleryText::filterValue($thunderForestKey) . ',';
                $o[] = '	attribution: \'© <a href="https://www.thunderforest.com/" target="_blank">Thunderforest</a>, © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
                $o[] = '}).addTo(map' . $this->name . $this->id . ');';
            } else {
                if ($type === 'mapbox') {
                    if ($mapBoxKey == '') {
                        $app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_API_KEY_NOT_SET'));
                        return false;
                    }
                    $o[] = 'L.tileLayer(\'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' . PhocaGalleryText::filterValue($mapBoxKey, 'url') . '\', {';
                    $o[] = '	maxZoom: 18,';
                    $o[] = '	attribution: \'Map data © <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors, \' + ';
                    $o[] = '		\'<a href="https://creativecommons.org/licenses/by-sa/2.0/" target="_blank" target="_blank">CC-BY-SA</a>, \' + ';
                    $o[] = '		\'Imagery © <a href="https://mapbox.com" target="_blank">Mapbox</a>\',';
                    $o[] = '	id: \'mapbox.streets\'';
                    $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                } else {
                    if ($type === 'opentopomap') {
                        $o[] = 'L.tileLayer(\'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png\', {';
                        $o[] = '	maxZoom: 17,';
                        $o[] = '	attribution: \'Map data: © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>, <a href="https://viewfinderpanoramas.org" target="_blank">SRTM</a> | Map style: © <a href="https://opentopomap.org" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>)\'';
                        $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                    } else {
                        if ($type === 'google') {
                            /*
                            $o[] = 'L.gridLayer.googleMutant({';
                            $o[] = '	type: googlemapstype,';
                            $o[] = '}).addTo(map'.$this->name.$this->id.');';
                            */
                        } else {
                            if ($type === 'wikimedia') {
                                $o[] = 'L.tileLayer(\'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png\', {';
                                $o[] = '	maxZoom: 18,';
                                $o[] = '	attribution: \'© <a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use" target="_blank">Wikimedia maps</a> | Map data © <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>\'';
                                $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                            } else {
                                if ($type == 'osm_fr') {
                                    $o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png\', {';
                                    $o[] = '	maxZoom: 20,';
                                    $o[] = '	attribution: \'© <a href="https://www.openstreetmap.fr" target="_blank">Openstreetmap France</a> & <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
                                    $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                                } else {
                                    if ($type == 'osm_hot') {
                                        $o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png\', {';
                                        $o[] = '	maxZoom: 20,';
                                        $o[] = '	attribution: \'© <a href="https://hotosm.org/" target="_blank">Humanitarian OpenStreetMap Team</a> & <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
                                        $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                                    } else {
                                        $o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {';
                                        $o[] = '	maxZoom: 18,';
                                        $o[] = '	attribution: \'© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
                                        $o[] = '}).addTo(map' . $this->name . $this->id . ');';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $this->output[] = implode("\n", $o);
    return true;
}