Posts by Spatial Galaxy

Leaflet Day 8 - Zoom to Feature

In this post we’ll add a zoom button to pan the map to one of the towns in the trail stops layer. Adding a Dropdown Box and Button The first thing to do is add the select element and a button to the HTML: <select id='zoombox'> </select> <input type="button" id="zoomTo" value="Zoom to town"> We’ll populate the options for the select element using the town GeoJSON. Creating a Dictionary and Populating the Select Box Next we loop through the towns in the GeoJSON layer and create a dictionary that maps the town name to its data, then add each as an option to a select element:
Learn More

Leaflet Day 7 - Coordinates

In this post, we’ll do a couple of things: Clean up the display of coordinate precision in our popups Add the current coordinates to the map as the mouse moves Coordinate Precision Display The current map displays the latitude and longitude with seven decimal places. This is more than we need to see when displaying information about locations: Fixing this is easy to do using the JavaScript function toFixed.
Learn More

Leaflet Day 6 - GeoPackage Layers

In this post we’ll switch gears and install Leaflet locally, then add a layer from a GeoPackage file. Installing Leaflet Up until now we’ve been using a hosted version of Leaflet. In other words, each time we load the map, a request is made to fetch the Leaflet CSS and JavaScript. There are a couple of ways to install Leaflet: download it from the website or install with npm. In both cases you’ll need to move leaflet.
Learn More

Leaflet Day 5 - Working with Features

Today we’ll add towns along the trail route that are mentioned in the novels. I hesitate to call them towns, because in 1902, many of them consisted of a view indigenous people and sometimes a roadhouse. The method to add these locations will be to add a GeoJSON layer and loop through each town, adding a marker and popup with some info. The Data The data for the locations is from the GNIS database for Alaska, containing over 35,000 locations.
Learn More

Leaflet Day 4 - Basemaps and Overlays

Today we’ll add some basemaps and a couple of controls to our map. So far we’ve been using OpenStreetMap as our back drop. There are a couple of tile servers that will give us a little more of a “back in the day” look. We’ll also add attribution to the map so we give credit where credit is due, as well as a scale bar. Complete code for the map can be viewed at the bottom of this post.
Learn More

Leaflet Day 3 - The Trail

Background In 1902 the only way from the port of Valdez to the Fortymile gold fields was a nearly 400 mile trail through the Alaska wilderness. The Valdez-Eagle trail plays a key role in novels two and three. Adding the Trail to a Leaflet Map To add the trail to our map, we will convert it from a shapefile to GeoJSON. There is more than one way to do this—you could use ogr2ogr, but we chose to use QGIS, since it would not only convert it, but transform the coordinate system at the same time.
Learn More

Leaflet Day 2 - Adding a Marker

I’m starting off slow, so today we’ll add a marker with some extra features. Since the map from yesterday is already centered on the big earthquake, lets add a marker there. Adding a Marker To create a marker, Leaflet uses the L.marker class: var earthquakeMarker = L.marker([61.346, -149.955]); This creates the marker, but it needs to be added to the map: earthquakeMarker.addTo(map); This gives us: Good so far, but looking at the map tells us nothing about the marker.
Learn More

Two Weeks of Leaflet - Day 1

Background We at Locate Press have been working on a new book: Leaflet Cookbook, by Numa Gremling. The book is chock-full of over 300 pages of recipes and information to get the most of your web maps. The book is content complete and available as a preview. I’ve dabbled in Leaflet in the past, but only scratched the surface. So, I’ve decided to spend two weeks starting from the ground up and create a decent web map.
Learn More

Plugin Builder 3.1

We’ve released version 3.1 of the Plugin Builder for QGIS 3.x. This version contains a number of bug fixes and performance enhancements. Here are some of the changes included since version 3.0.3: Fix issue with reload on generated plugins Move dialog creation to run method to improve startup performance Move help file generation files to proper method Include missing tags file Attempt to compile resources.qrc when plugin is generated (requires pyrcc5 in path) Set deployment directory in Makefile based on user OS (pb_tool is recommended over make) Check for valid URL format for tracker and repository Compiling Resource File If you have the resource compiler pyrcc5 in your path, the resource file will be compiled automatically when you generate your new plugin.
Learn More

Where's my .qgis3 Folder?

There’s been several posts to GIS StackExchange along the lines of: Where’s my .qgis3 folder? Prior to QGIS 3, the .qgis/.qgis2 folder was found under your home directory. At version 3, the folder has moved to a more standard profile location for your operating system. There are a couple of ways to determine where the folder is located: Use the Settings->User Profiles->Open active profile folder menu item Use QgsApplication.qgisSettingsDirPath from Python or the console Here are the “standard” locations for Linux, Mac, and Windows, as found under your HOME directory:
Learn More