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

Accessing street line data #723

Closed
bnolan opened this issue Aug 23, 2014 · 13 comments
Closed

Accessing street line data #723

bnolan opened this issue Aug 23, 2014 · 13 comments

Comments

@bnolan
Copy link

bnolan commented Aug 23, 2014

I'm trying to use a physics engine to constrain people so they can only walk around the city on visible roads. I can't see any way to get the street centerline data out of mapbox gl. Can someone give me pointers on where to start looking for the centerline data for streets? I'm happy to share a demo showing how to use the data or contribute to an API if people can give me some pointers. :)

@mourner
Copy link
Member

mourner commented Aug 23, 2014

Try using map.featuresAt method, passing geometry: true in the options https://www.mapbox.com/mapbox-gl-js/api/

@bnolan
Copy link
Author

bnolan commented Aug 25, 2014

I've got the map working correctly here, but when I call featuresAt, I don't get anything returned in the callback.. Any ideas?

map.featuresAt([100,100], {geometry : true, radius : 30}, function(a,b){console.log(a,b)});

@bnolan
Copy link
Author

bnolan commented Aug 25, 2014

I investigated this a bit, and it seems that this.data in rbush#search doesn't have any content in it.

{"children":[],"leaf":true,"bbox":[null,null,null,null],"height":1}

@bnolan
Copy link
Author

bnolan commented Aug 25, 2014

Neither of the loaded tiles haves data in their rtrees. :(

@bnolan
Copy link
Author

bnolan commented Aug 25, 2014

Okay, there's a bug in createBucket.js:31 where interactive is not being set to true for the mapbox source. Hardcoded it to true and it works now. What projection are the tiles in? I'm getting integers like {x : 2883, y : 380}.

@bnolan
Copy link
Author

bnolan commented Aug 25, 2014

Okay, sorry for spamming here - but is there a way to convert the _geometry included in features back into latitude / longitude? It seems that the _geometry is returned in the extent of the tile it came from, but I can't see any way of working out which tile the _geometry is from?

@mourner
Copy link
Member

mourner commented Aug 26, 2014

Okay, there's a bug in createBucket.js:31 where interactive is not being set to true for the mapbox source

Is this a bug? You need to explicitly set interactive: true in the style for the layer to make it work, otherwise it's disabled. This is done for performance.

Will look into lat/lng task...

@bnolan
Copy link
Author

bnolan commented Aug 26, 2014

How do you set interactive: true in the style? I couldn't find any examples of that. Setting interactive : true on the map doesn't seem to work.

@mourner
Copy link
Member

mourner commented Aug 26, 2014

In the style JSON, just put interactive: true as one of the properties of a layer that you'll later query with featuresAt.

@mourner mourner added this to the future milestone Aug 27, 2014
@bnolan
Copy link
Author

bnolan commented Aug 27, 2014

I made a demo of what I'm using featuresAt for.

@mourner
Copy link
Member

mourner commented Aug 27, 2014

Oh, nice! So, would including info about the tile (coords/zoom) in the query response suffice for your use case?

@bnolan
Copy link
Author

bnolan commented Aug 27, 2014

Sure, that'd be great. I can convert from tile coords to lat lng. :)

@jfirebaugh
Copy link
Contributor

Fixed with #1010.

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

No branches or pull requests

3 participants