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

Make "maps by region" readable in JSON API #251

Closed
jywarren opened this issue Feb 6, 2018 · 2 comments
Closed

Make "maps by region" readable in JSON API #251

jywarren opened this issue Feb 6, 2018 · 2 comments

Comments

@jywarren
Copy link
Member

jywarren commented Feb 6, 2018

This action allows listing maps by region:

# list by region
def region
area = params[:id] || "this area"
@title = "Maps in #{area}"
ids = Map.bbox(params[:minlat],params[:minlon],params[:maxlat],params[:maxlon]).collect(&:id)
@maps = Map.where(password: '').where('id IN (?)',ids).paginate(:page => params[:page], :per_page => 24)
render "maps/index", :layout => "application"
end

Example:

https://mapknitter.org/map/region/Gulf-Coast?minlon=-98.8&minlat=23.6&maxlon=-79.1&maxlat=31.8

We should add something like this line to make it respond to JSON queries too - that way we can display maps on external sites by region:

format.json { render :json => @maps }

@sagarpreet-chadha
Copy link
Contributor

Hi @jywarren 😄 !
We have to add format.json { } only in region action of maps_controller ?
And link in the example above is not working .
Thanks !

jywarren added a commit that referenced this issue May 29, 2018
Make "maps by region" readable in JSON API #251
@jywarren
Copy link
Member Author

Completed by @sagarpreet-chadha !!!

https://mapknitter.org/map/region/Gulf-Coast.json?minlon=-98.8&minlat=23.6&maxlon=-79.1&maxlat=31.8

Could use a test maybe, but looking great!

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

2 participants