Skip to content

addGeoJSON() fails to render valid geometries #622

@aoles

Description

@aoles

Hi,

it seems that geoJSON geometry primitives such as "Point" or "Polygon" are not displayed by addGeoJSON(). I would expect them to be valid input as according to the specification and to geojsonlint::geojson_validate() they conform to the standard.

Cheers,
Andrzej

library(leaflet)
library(jsonlite)
library(geojsonlint)

polygon = list(
  type = "Polygon",
  coordinates = list(
    list(
      c(8.330469, 48.261570),
      c(8.339052, 48.261570),
      c(8.339052, 48.258227),
      c(8.330469, 48.258227),
      c(8.330469, 48.261570)
    )
  )
)

geojson_validate(toJSON(polygon, auto_unbox = TRUE))
#> [1] TRUE

leaflet() %>%
  addTiles() %>%
  addGeoJSON(polygon, color="#F00") %>%
  setView(lng = 8.330469, lat = 48.26157, zoom = 15)

feature <- list(
  type = "Feature",
  properties = "",
  geometry = polygon
)

leaflet() %>%
  addTiles() %>%
  addGeoJSON(feature, color="#F00") %>%
  setView(lng = 8.330469, lat = 48.26157, zoom = 15)

Created on 2019-05-03 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: noviceAnyone could helpeffort: low< 1 day of workhelp wantedSolution is well-specified enough that any community member could fixpriority: mediumCould be fixed before next release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions