mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

Document "Carmen format" more precisely

Open stevage opened this issue 5 years ago • 7 comments

The localGeocoder property is a function which returns results in the Carmen GeoJSON format. However, this statement is not enough to tell you which fields your function must provide.

It is also a bit loose, as the documentation for that format shows a FeatureCollection, whereas mapbox-gl-geocoder expects an array of Features.

stevage avatar May 09 '20 03:05 stevage

The API doc links through to https://github.com/mapbox/carmen/blob/master/carmen-geojson.md which documents this, however you're right it doesn't show which fields are required. I think it's okay to document the required fields.

The API doc says "Expected to return an Array of GeoJSON Features" so it's clear it shouldn't be a FeatureCollection, feel free to suggest better wording if you think it could be made clearer.

andrewharvey avatar May 09 '20 03:05 andrewharvey

I think a quick statement to the effect, "In particular, the center, place_name and text attributes are required".

stevage avatar May 09 '20 03:05 stevage

I think a quick statement to the effect, "In particular, the center, place_name and text attributes are required".

I haven't checked but I think place_name is only required if you're using the default getItemValue option, if you supply your own getItemValue then place_name is not required.

Is text required? I did a quick look and didn't see where, I'm probably missing it.

I can help review a PR if you wanted to propose a change :wink:

andrewharvey avatar May 09 '20 04:05 andrewharvey

The thought occurs to me that if so few fields are actually used, then it's probably just adding unnecessary complication to even refer to the Carmen format. It's probably simpler to simply document the three fields in question.

stevage avatar May 09 '20 09:05 stevage

My thinking was the localGeocoder should return results in the same format as the Mapbox Geocoding API so that results could be consistently formatted together. I can't remember why I choose to mention carmen's documentation directly and not https://docs.mapbox.com/api/search/#geocoding-response-object.

I don't see any issue with changing it to document only what's required, and then also what's optional (eg. bbox is used if given but not required).

andrewharvey avatar May 10 '20 07:05 andrewharvey

The link https://github.com/mapbox/carmen/blob/master/carmen-geojson.md is dead now.

3zzy avatar Dec 09 '22 03:12 3zzy

The link https://github.com/mapbox/carmen/blob/master/carmen-geojson.md is dead now.

https://web.archive.org/web/20210224184722/https://github.com/mapbox/carmen/blob/master/carmen-geojson.md

dawsoncanby avatar Feb 15 '23 17:02 dawsoncanby