OpenLayers $geolocation_default_bounds ? how to set

132 views
Skip to first unread message

Jay Lepore

unread,
Feb 2, 2022, 1:46:42 PM2/2/22
to ResourceSpace
I see there is a feature for utilizing OpenLayers and the default config in my case gives an example:

# For example, to specify the USA use: #$geolocation_default_bounds="-10494743.596017,4508852.6025659,4";

However I have not been able to find out 'where' I can get these settings from.  It is not a typical longitude / latitude in that there's a ,4 appended to the end. 

Does anyone know where to scrape this setting from based on my desired location?

Thanks.

Jeff Nova

unread,
Feb 2, 2022, 11:40:37 PM2/2/22
to ResourceSpace
OpenLayers does "Longitude, Latitude, Zoom Level" though it's possible that RS switches Lat and Long internally to accommodate more intuitive ordering for many users.  - J

--
ResourceSpace: Open Source Digital Asset Management
http://www.resourcespace.com
---
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resourcespac...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/resourcespace/0f02b499-82df-4894-8a7f-3b524e642161n%40googlegroups.com.

Mark Leo-Russell

unread,
Feb 3, 2022, 12:17:50 PM2/3/22
to ResourceSpace
Jay, Jeff--

If you're using Resource Space 9.6 or above, they changed from OpenLayers to LeafMaps so the configuration is considerably different. I posted about this a few months back but I'll repeat here for your convenience.

The documentation on RS's site got me through most of the configuration (https://www.resourcespace.com/knowledge-base/systemadmin/leafletmaps). The biggest problem I ran into with the new mapping piece of 9.6 was understanding the geo coordinates used to display the default map when you do a geographic search. Turns out the lat/long coordinates need to be specified in EPSG:3857 format. This site has a handy converter if you're used to decimal degrees or DDMMSS format: https://epsg.io/transform#s_srs=3857&t_srs=3857.  
   '
   '
   '
With LeafMaps in Resource Space, I didn't use a bounding box. Rather, once I figured out the EPGS:3857 coordinates, I set the center of our map area and then experimented with the zoom value until I had the map extent I wanted (in our case, a zoom value of 6)....

One of the confusing things I ran into in configuring LeafMaps in RS 9.6 is the config files still have lots of stuff from the previous versions that used OpenLayers for the mapping. Changing many of those options had no effect in 9.6. I stayed with using the default USGS base maps but you can use other map sources. See my config.php code below (esp. red section).

One other thing I've run into with its mapping features. Resource Space stores coordinates in two places: the 'resource' table and the 'resource_data' table. The latter is where lat/longs go when entered as a resource's metadata. However, the mapping components use the location in the 'resource' table. You can enter both when you edit the metadata but we're working on an automated query that will copy lat/longs from 'resource_data' to 'resource' as part of the nightly maintenance jobs that run on our RS server (save our folks from having to enter the data twice and avoids coordinate mis-matches between the two DB tables). Also, if you want the heat maps to work, you need to have the 'batch/cron-jobs/014_update_heatmap.php' script run on a regular basis. For us that's another scheduled nightly job. 

Hope that helps...

Mark

=====BEGIN: code segment from config.php=====
    // New settings for leaflet maps
    $leaflet_maps_enable = true;

    // $geo_leaflet_maps_sources: Use the standard tile sources provided by leaflet maps?
    // If this is enabled please refer to /include/map_basemaps to see the available config options that enable specific defined map providers
    $geo_leaflet_maps_sources = true;
    $map_usgstopo = true;
    $map_usgsimagery = true;
    $map_usgsimagerytopo = true;

    // $geo_leaflet_sources = define available tile servers.
    // Configured sources need to follow the default template as below
    $geo_leaflet_sources = array();
    $geo_leaflet_sources[] = array(
        "name"          => "The National Map",
        "code"          => "USGSTNM",
        "url"           => "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}",
        "maxZoom"       => 8,
        "detectRetina"  => true,
        "attribution"   => "<a href=\"https://www.doi.gov\">U.S. Department of the Interior</a> | <a href=\"https://www.usgs.gov\">U.S. Geological Survey</a>",

        "default"       => true,
        "extension"     => "jpeg",
        "variants"      => array(
            "USTopo"        => array(
                "name"          => "US Topographic",
            ),
            "USImagery"     => array(
                "name"          => "US Imagery",
                "url"           => 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}',
                ),
            "USImageryTopo" => array(
                "name"          => "US Imagery & Topographic",
                "url"           => 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/{z}/{y}/{x}',
            ),
            )
        );

    // Limit number of search results that can be displayed in map view. Set to 0 for no limit
    $search_map_max_results = 5000;
   
    // Use zoom slidebar instead of standard +/- buttons?
    $map_zoomslider = true;

    // Leaflet: Show zoom history navigation bar?
    $map_zoomnavbar = true;

    // Leaflet: Cache map layer tiles in the browser (recommended to reduce tile server load)?
    $map_default_cache = true; # Default basemap?
    $map_layer_cache = true; # All basemaps?

    // Enable retina display tiles (four tiles of half size and a larger zoom level in place of one to utilize higher resolution)?
    $map_retina = false;

    // Leaflet: default basemap to show
    // Set to be '{CODE}.{variant} - matching the definitions from the $geo_leaflet_source code array
    // e.g. "OSM.Mapnik"
    $map_default = 'USGSTNM.USTopo';

    // Open resource when clicking on a search result marker, instead of resource tooltip?
    $marker_resource_preview = true;

    // Leaflet: Custom map marker coloring based on a selected numeric value metadata field, instead of coloring by resource type, enable by setting a metadata field ID and descriptive text value.
    # $marker_metadata_field = 85; # Example is fieldID 85.
    $lang['custom_metadata_markers'] = ''; # Custom metadata field map legend header text.

    // Array of minimum and maximum numeric values for the markers on the map, up to eight marker pairs (min >=, max <=) when using custom marker coloring.  Example below shows a range of years.
    $marker_metadata_array = [
        0 => ['min' => 1935, 'max' => 1939], # Blue marker
        1 => ['min' => 1940, 'max' => 1949], # Red marker
        2 => ['min' => 1950, 'max' => 1959], # Green marker
        3 => ['min' => 1960, 'max' => 1969], # Orange marker
        4 => ['min' => 1970, 'max' => 1979], # Yellow marker
        5 => ['min' => 1980, 'max' => 1989], # Black marker
        6 => ['min' => 1990, 'max' => 1999], # Grey marker
        7 => ['min' => 2000, 'max' => 2010], # Violet marker
        8 => ['min' => 2010, 'max' => 2020]  # Gold marker
    ];

    // Leaflet: Show a KML overlay on the map?
    $map_kml = false;
    $map_kml_file = ''; # Place KML file in ../filestore/system/, example: overlay.kml

    // Resource metadata field integer ID containing polygon footprint location string, blank '' if not used.  String in (latitude, longitude) coordinate pairs separated by a comma: (40.75,-111.51), (40.75,-111.49), (40.73,-111.49), (40.73,-111.51) or using braces [].  String can also contain a fifth pair that closes the polygon and equal to the first pair.
    # $map_polygon_field = 84;

// Option to add a 'heatmap' when performing a geographic search to aid searching
// Heatmap data relies on presence of a file that is generated by a ResourceSpace cron job (scheduled task)
// Please note the following:-
//  - This should be disabled in multi-client environments
//  - Cached location co-ordinates are rounded to one decimal place to improve handling of large numbers of resources
//  - Only resources that are currently in the default search states will be included in the heatmap
//  - This can be enabled per usergroup as a configuration option
$geo_search_heatmap = true;


# 2021-07-13 Added from https://www.resourcespace.com/knowledge-base/systemadmin/leafletmaps
#            Default center and zoom for map ('-10494743.596017,4508852.6025659,4' = USA)
# Center on USA 48
#$geolocation_default_bounds="-10494743.596017,4508852.6025659,4";
###
### NOTE: Resource Space uses EPSG:3857 coordinates [ref: https://epsg.io/transform#s_srs=3857&t_srs=3857]
###
# Center on NMBGMR [Lon/Lat]: -106.90424, 34.06826 => [EPSG:3857] -11900444.30, 4037901.48
$geolocation_default_bounds="-11900444.30,4037901.48,6";


=====END: code segment from config.php=====  
Reply all
Reply to author
Forward
0 new messages