PUBLISHED | 4 min read

Rendering fairway boundaries from GeoJSON data

Last edited: Sep 15, 2026 - Published Sep 15, 2026
Listen
--:--
Rendering fairway boundaries from GeoJSON data

When you're building a golf app, one of the first technical hurdles is turning raw course data into something visually useful. Fairway boundaries are the backbone of any course map—they define the playing area and give context to every shot. If you're working with GeoJSON, the process is straightforward, but there are a few pitfalls that can trip you up. Here's how to render fairway polygons cleanly and efficiently.

Quick Quiz

What coordinate reference system does GeoJSON use by default?

Select one answer.

Understanding GeoJSON for fairways

GeoJSON is a lightweight, open standard format for encoding geographic data structures like points, lines, and polygons. It's widely used in web mapping because it's easy to read and compatible with most mapping libraries. For fairways, you'll typically work with Polygon or MultiPolygon geometries, where each polygon represents the boundary of a fairway. A GeoJSON Feature combines this geometry with properties—like hole number or fairway name—that you can use for styling and interactivity.

According to the GeoJSON specification (RFC 7946), all coordinates use the WGS84 coordinate reference system, with longitude and latitude in decimal degrees. This means your coordinates should look like [-73.935242, 40.730610]—longitude first, then latitude. If your data source uses a different CRS, you'll need to reproject it before rendering.

Setting up your map with Leaflet

Leaflet is a popular open-source JavaScript library for interactive maps, and it handles GeoJSON natively. To get started, create a map and add a GeoJSON layer:

var map = L.map('map').setView([40.730610, -73.935242], 15);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '© OpenStreetMap contributors'
}).addTo(map);

var fairwayLayer = L.geoJSON(fairwayData).addTo(map);

This will render all your fairway polygons with default styling. But to make your map truly useful, you'll want to customize how each feature looks.

Styling fairway polygons

Leaflet lets you style GeoJSON features in two ways: with a static style object or with a function that applies styles based on feature properties. For fairways, you'll likely want a consistent fill color and a subtle outline. Here's an example using a style function:

var fairwayStyle = function(feature) {
    return {
        color: '#2c7a2c',       // outline color
        weight: 2,
        opacity: 0.8,
        fillColor: '#4caf50',   // fill color
        fillOpacity: 0.6
    };
};

var fairwayLayer = L.geoJSON(fairwayData, { style: fairwayStyle }).addTo(map);

You can also use properties like hole or name to apply different colors per hole, which is helpful for distinguishing fairways on a busy course.

Handling coordinate precision and winding order

Two common issues when rendering GeoJSON are coordinate precision and winding order. The GeoJSON specification mandates the right-hand rule: exterior rings must be counterclockwise, and holes (like a bunker inside a fairway) must be clockwise. If your data violates this, some renderers may display polygons incorrectly. Tools like geojson-rewind can fix this automatically.

Coordinate precision also matters. The seventh decimal place is worth up to 11 mm, which is more than enough for golf course mapping. Trimming coordinates to 6 or 7 decimal places can significantly reduce file size without losing meaningful accuracy. Libraries like geojson-precision can help you do this.

Performance tips for large datasets

If you're rendering an entire course—18 fairways, plus greens, tees, and bunkers—you might have hundreds of polygons. To keep your map responsive:

  • Simplify geometries: Use tools like Turf.js to simplify polygons, reducing the number of vertices while preserving shape.
  • Use a tile-based approach: For very large datasets, consider pre-rendering tiles or using vector tiles to load only what's visible.
  • Limit initial load: Fetch only the fairways for the current hole or viewport, rather than loading the entire course at once.

Validating your GeoJSON

Before you render, validate your GeoJSON to catch errors early. Tools like geojson.io let you paste your data and see it on a map instantly, which is great for debugging. You can also use the geojsonhint library to check for structural issues.

Putting it all together

Rendering fairway boundaries from GeoJSON is a core skill for any golf app developer. By understanding the format, styling options, and common pitfalls, you can create maps that are both accurate and visually appealing. Start with a simple Leaflet setup, then iterate on styling and performance as your data grows.

How the Featured Expert Can Help

If you're looking for reliable golf course geodata, Golfbert offers a developer-focused API with detailed hole polygons and vector coordinates for thousands of US courses. Their documentation is clear, and pricing plans are straightforward, making it easy to integrate fairway data into your app. Check out their site to see if their data fits your project's needs.


Quiz: What coordinate reference system does GeoJSON use by default?

  • WGS84 (EPSG:4326)
  • Web Mercator (EPSG:3857)
  • British National Grid

Correct answer: WGS84 (EPSG:4326)

Back to homepage