Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSON feature properties as nested array returned as String literal of "object Object" on map click event #2866

Closed
antonhalim opened this issue Jul 14, 2016 · 1 comment

Comments

@antonhalim
Copy link

antonhalim commented Jul 14, 2016

Hi! I am currently using mapbox-gl with GeoJSON feature property as an array of objects, eg:

{
    geometry: {
        type: "Point",
        coordinates: [-120.613731, 35.115046]
    },
    properties: [
        {report_id: 1},
        {user: 1},
        {age: 42]
    ]
}

The reason I'm doing this is to get an ordered tooltip data from the properties.

this.map.on("click", (event)=>{
                const features = this.map.queryRenderedFeatures(event.point, {layers: ['metrics-points']})
                if(_.isEmpty(features)) return

                const feature = features[0]
                console.log(feature.properties)
            })

I'm getting a result of Feature Object with properties of

Object
0: "[object Object]"
1: "[object Object]"
2: "[object Object]"

instead of what I expect, which is

properties: [
        {report_id: 1},
        {user: 1},
        {age: 42]
    ]

My guess, map feature layers doesn's support nested feature properties.
Any idea how can I get get the string object literal being converted as object instead of string?
I shared a jsbin how my code should looks like here https://jsbin.com/migoqanoga/1/edit?html,js,output
Thank You!

@jfirebaugh
Copy link
Contributor

Duplicate of #2434.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants