Plots2: ability to refresh displayed inline maps' displayed data when you pan/zoom

Created on 8 Jan 2018  ·  20Comments  ·  Source: publiclab/plots2

Please describe the problem (or idea)

You can embed inline maps using this inline powertag: https://publiclab.org/wiki/inline-maps

The code driving this is here:

https://github.com/jywarren/plots2/blob/184eced60d9d6842cad8df469bb1df2838528522/app/models/concerns/node_shared.rb#L102-L124

And the template is here: https://github.com/jywarren/plots2/blob/master/app/views/map/_leaflet.html.erb

However, when you drag the map, the markers aren't refreshed for the new viewing area.

Let's break this in three:

  1. [x] let's make an API call for data near a point, similar to https://publiclab.org/api/srch/notes?srchString=foo but perhaps https://publiclab.org/api/srch/notes?geo=41.0,-91.3. This could be built out from https://github.com/publiclab/plots2/blob/master/app/api/srch/search.rb#L52-L72, or a new method could be made
  2. [x] let's rewire https://github.com/jywarren/plots2/blob/184eced60d9d6842cad8df469bb1df2838528522/app/models/concerns/node_shared.rb#L102-L124 to load a blank map which then loads the API call for the center point, and displays notes as points on hearing back from the API
  3. [x] let's set the inline map to re-fetch notes near its center point each time the map is panned or zoomed

This is a big multi-part issue that we can solve in three or more steps. Anyone interested in breaking out the first one?

JavaScript Ruby break-me-up enhancement help wanted

Most helpful comment

awesome plugin -- yes perfect!

On Fri, Mar 30, 2018 at 4:07 PM, Sagarpreet Chadha <[email protected]

wrote:

@jywarren https://github.com/jywarren , @Gauravano
https://github.com/Gauravano ! Can i also solve this issue ?
The code may be used later if we decide to make a library .
What do you think ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1934#issuecomment-377611018,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ9bk4gUyLKBbJxS-Qj76NBQY8i2bks5tjpCUgaJpZM4RXAwK
.

All 20 comments

@jywarren I want to try this one

hi, this is a big project but i'd be happy to help you tackle it piece by
piece. Thanks and open a PR sooner rather than later! Thanks!!

On Tue, Jan 9, 2018 at 4:38 AM, Gaurav Sachdeva notifications@github.com
wrote:

@jywarren https://github.com/jywarren I want to try this one


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1934#issuecomment-356231179,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJznVKoASY6PwMeUjiG4l7JCpM8vwks5tIzOmgaJpZM4RXAwK
.

Hi @jywarren, I was just considering all the steps as stated by you.I think(not sure) we can change the flow as - instead of making call to API for near points, can't we modify https://github.com/jywarren/plots2/blob/184eced60d9d6842cad8df469bb1df2838528522/app/models/concerns/node_shared.rb#L102-L124 such as it will receive center point from us and provide us near points and each time pan/zoom is detected we would call the function .The inline tag will be dealt by making an additional function which has to be used only when we have to load the page and at other times we will just give center coordinates to function.

What do you think about this?

Hmm, well you definitely highlighted the code section we want. I think we
could make another function for this (maybe this is what you're saying)
like "Node.near()" or something, call it here, but then also provide a way
the client side can call it too. But this last way of calling it externally
seems like it ought to be via the API, a more universal interface we can
offer to others for use. What do u think?

On Jan 10, 2018 5:38 PM, "Gaurav Sachdeva" notifications@github.com wrote:

Hi @jywarren https://github.com/jywarren, I was just considering all
the steps as stated by you.I think(not sure) we can change the flow as -
instead of making call to API for near points, can't we modify
https://github.com/jywarren/plots2/blob/184eced60d9d6842cad8df469bb1df
2838528522/app/models/concerns/node_shared.rb#L102-L124 such as it will
receive center point from us and provide us near points and each time
pan/zoom is detected we would call the function .The inline tag will be
dealt by making an additional function which has to be used only when we
have to load the page and at other times we will just give center
coordinates to function.

What do you think about this?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1934#issuecomment-356761050,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ7Dnhw745kz9E6P67nx_q16MihNpks5tJTu0gaJpZM4RXAwK
.

Hmm...making API can definitely be useful for future implications of this feature so ok, I will stick with your above-stated flow and will open pull soon for the first part.Also, plz suggest changes in #1935 .Thank you.

Hi jeff I have used https://github.com/publiclab/plots2/blob/01fac7cda6ab3df0ee9ba492f489edeef741ece9/app/models/concerns/node_shared.rb#L122-L146 for fetching coordinates, the function given on your repo's link i.e., https://github.com/jywarren/plots2/blob/184eced60d9d6842cad8df469bb1df2838528522/app/models/concerns/node_shared.rb#L102-L124 is using DrupalNodeCommunityTag model which is not used now

Aha, true -- thanks! We updated that since.

@jywarren and @Gauravano , i was wondering if i can do the 2nd and 3rd part of this issue ? This will be exciting !! 😄

I think you could start work on the 2nd while the first is finishing up,
with a PR; maybe @Gauravano would like to take the final part?

Thanks! There'll be a 4th part too about a search box to search the map for
additional locations to zoom to.

On Jan 13, 2018 3:18 PM, "Sagarpreet Chadha" notifications@github.com
wrote:

@jywarren https://github.com/jywarren and @Gauravano
https://github.com/gauravano , i was wondering if i can do the 2nd and
3rd part of this issue ? This will be exciting !! 😄


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1934#issuecomment-357464375,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ1UXCiij_f-iYkgYLuypqD_FHr19ks5tKQ9egaJpZM4RXAwK
.

Okay , working on second one . Thanks 😄 .

Hey @jywarren and @Gauravano , the JSON format of the new API is :

screen shot 2018-01-16 at 6 46 45 pm

To add markers to maps , we will also need Latitude and Longitude value of each node .
@Gauravano Can you also add Latitude and Longitude value of each node also in API ? Thanks 😄 !

Actually @jywarren I just noted right now that the API I built is fetching all the nodes but what if someone on wiki page used an inline tag like [map: tag:infragram:lat:lon] then, we don't have API for that.So, we need to have 2 different URL one for notes and one for notes with tag.What do you think?Am I talking right?

Good call -- I think you're right, but we can start the implementation on the 1st, more simple type of query, see how it performs, then create a follow-on task for the tag-based ones.

(If you need to split out a new view for the refreshable map, that's fine -- it's probably good to have a simpler implementation present as long as it works very similarly!)

Modularity! :-)

Ok then @sagarpreet-chadha as per your requirement ,I am updating the API for now

OK, the API step is done and merged! Reopening for the remaining parts :-)

We can use this plugin : http://labs.easyblog.it/maps/leaflet-search/ for searching locations on maps (got idea from your comment here ) . What do you think @jywarren ?

@jywarren , @Gauravano ! Can i also solve this issue ?
The code may be used later if we decide to make a library .
What do you think ?

awesome plugin -- yes perfect!

On Fri, Mar 30, 2018 at 4:07 PM, Sagarpreet Chadha <[email protected]

wrote:

@jywarren https://github.com/jywarren , @Gauravano
https://github.com/Gauravano ! Can i also solve this issue ?
The code may be used later if we decide to make a library .
What do you think ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1934#issuecomment-377611018,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ9bk4gUyLKBbJxS-Qj76NBQY8i2bks5tjpCUgaJpZM4RXAwK
.

This would be really amazing to pick back up!

https://publiclab.org/wiki/inline-maps

Solved in #4382

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bronwen9 picture bronwen9  ·  3Comments

jywarren picture jywarren  ·  3Comments

noi5e picture noi5e  ·  3Comments

milaaraujo picture milaaraujo  ·  3Comments

first-timers[bot] picture first-timers[bot]  ·  3Comments