3

Is there a correct way of including links to images within geoJSON?

This is the FeatureCollection I have for an object on my site:

{
  "type": "FeatureCollection",
  "features": [
    {
      "id": 1234,
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -0.322825,
          51.065361
        ]
      },
      "properties": {
        "popupContent": "In loving memory of\r\nGordon Wiseman\r\n15.4.30 ~ 11.8.06\r\nWho spent many happy hours\r\nin this park"
      }
    }
  ]
}

I also want to include the links to multiple images. Is it OK to add another property? For example:

"properties": {
    "popupContent": "In loving memory of\r\nGordon Wiseman\r\n15.4.30 ~ 11.8.06\r\nWho spent many happy hours\r\nin this park",
    "media": [
        "https://example.com/image1.jpg",
        "https://example.com/image2.jpg"
    ]
}

Or is there a better / more standard way of doing it?

3

AFAIK GeoJSON is standardized by the Internet Engineering Task Force (IETF), and the standard mainly defines the implementation of geographic objects.

The properties are based on and extended from the {key: value} structure of JSON itself; you can populate it with anything that fits this concept.

The exact contents should be tailored to the parsing capabilities of your target software; it's likely some frameworks/systems can automatically parse image URLs from a dedicated property.

For interchangeability, I would probably stick to the standard properties: {key: value}, just like you did.

In many applications, properties are treated as attributes/field/columns...you can add as many as the target system allows. However, I would avoid furrther nesting of property objects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.