Skip to content

Unable to assign string directly to popup using master branch #259

Closed

Description

@jelmelk

Doing some small testing and I did the follwing:

some_marker = folium.Marker(location=[45.5215, -122.6261], popup='test')

I would get this error: AttributeError: 'str' object has no attribute 'get_name'. If I change that to popup=folium.Popup('test') it works fine. Is that intended?

Main reason I'm asking is because it seems somewhat tedious having to call that to assign a string to the popup.

Activity

  1. changed the title [-]Unable to call popup using master branch[/-] [+]Unable to assign string to popup using master branch[/+] on Nov 27, 2015
  2. changed the title [-]Unable to assign string to popup using master branch[/-] [+]Unable to assign string directly to popup using master branch[/+] on Nov 27, 2015
  3. BibMartin commented on Nov 27, 2015

    @BibMartin
    Contributor

    @jelmelk

    Is that intended?
    Main reason I'm asking is because it seems somewhat tedious having to call that to assign a string to the popup.

    In the background, we cannot do without the Popup object, because one may be willing to create more complicated popups (with a vega chart for instance).

    But I agree it's tedious, and in the foreground we can shortcut things in the Marker code to catch cases when the arg popup is a str (or bytes), and to replace it by Popup(popup).

    It'd be great if you did a PR for that (and thus join the happy community of contributors). Otherwise, I'll do it on Monday.

  4. jelmelk commented on Nov 27, 2015

    @jelmelk
    ContributorAuthor

    I'm looking at that right now. Would it be better to change each marker individually since the error rises at map.py on line 389 for Marker and element.py on line 414 for CircleMarker etc...

    They all have element.py line 46 in common which is where the exception is actually being called from. What would be the preference in this case?

  5. BibMartin commented on Nov 27, 2015

    @BibMartin
    Contributor

    I imagine you can simply fix it in the Marker.__init__ is testing when isinstance(popup,text_type) or isinstance(popup,str_type) and then overwrite the popup attribute.

  6. themiurgo commented on Nov 30, 2015

    @themiurgo
    Contributor

    We should strive to generalise this, while we're at it. You might want to have a popup also for Polylines, for example.

  7. added this to the milestone on Dec 3, 2015
  8. added
    enhancement
    on Dec 3, 2015
  9. BibMartin commented on Dec 6, 2015

    @BibMartin
    Contributor

    Fixed by #283. Closing this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions