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

Popup state #77

Open
drwlrsn opened this issue Oct 18, 2014 · 6 comments
Open

Popup state #77

drwlrsn opened this issue Oct 18, 2014 · 6 comments

Comments

@drwlrsn
Copy link

drwlrsn commented Oct 18, 2014

I was wondering if anyone had any ideas on how to reflect the popup state in the URL.
For example, if I had a map with a bunch of POIs and a user clicked the marker for a particular market, it would be great if the URL would change something like /supermarkets/3424 or /supermarket/<some controller property>.

I have been digging around descending SomeCollectionLayer._childLayers[n]._childLayers[n]. This seems like the really wrong way to do this. How should I approach this problem?

@miguelcobain
Copy link
Collaborator

You're suggesting having a link-to inside a popup? Or clicking a popup would trigger a transition to a different route?

@drwlrsn
Copy link
Author

drwlrsn commented Oct 18, 2014

Clicking a popup would trigger a transition to a different route. And then the reverse: if the app is loaded with the route, the popup is open.

@miguelcobain
Copy link
Collaborator

The reasoning would be to change the model through the router and make the marker react accordingly to the model.

Example:

  • enter route: /restaurants/1
  • Make a selected property in the restaurants controller to hold the currently selected restaurant.
    or
  • set a highlighted property to true in the restaurant 1 model
  • observe this property in your MarkerLayer subclass and act accordingly (open the popup in this case)

@nickiaconis
Copy link
Collaborator

What if popups were componentized as compositional components:

{{#ember-leaflet}}
  {{tile-layer tileUrl="//a.tiles.mapbox.com/v3/examples.map-zr0njcqy/{z}/{x}/{y}.png"}}
  {{#container-layer}}
    {{#each enabledLocations as |location|}}
      {{#marker-layer location=location.location}}
        {{#marker-popup}}
          <p>Some HTML content goes here, potentially including {{boundProperties}} or <button {{action "doSomething"}}>actionable elements</button> which get handled by the parent route/component.</p>
        {{/marker-popup}}
      {{/marker-layer}}
    {{/each}}
  {{/container-layer}}
{{/ember-leaflet}}

So to reflect popup content in the URL you would do:

{{#marker-popup}}
  {{outlet}}
{{/marker-popup}}

And let Ember's router take care of the rest by using nested routes.

@miguelcobain
Copy link
Collaborator

As you know, related: #98 (comment)
Something like that is planned for future versions.

@nickiaconis
Copy link
Collaborator

Yep, I remember that. Basically, it solves this case with very little "heavy lifting" on EmberLeaflet's side. Plus it looks a lot cleaner and is generally more flexible than something like {{popup-marker-layer popupContent=someComputedProp}}.

This is just a thing to keep in mind when implementing those components.

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

3 participants