I’m having difficulties inserting a hyperlink to the map markers.
This is the map I created of NYC schools: map_of_schools
schools= for i in interest_areas: df_sub=df4[df4.interest1==i] school = dict( type = 'scattermapbox', locationmode = 'USA-states', lon = df_sub['Longitude'], lat = df_sub['Latitude'], sizemode = 'diameter', mode='markers', marker = dict( size = (df_sub['Performance']*10)**1.8, line = dict(width = 2,color = 'black') ), # legend name name = df_sub['interest1'].values, #legend interest name hovertext=df_sub['text'], hoverlabel=dict(namelength=-1), hoverinfo='name+text' ) schools.append(school) layout = dict( autosize=True, hovermode='closest', hoverdistance=2, title='NYC High Schools<br>(bubble sized according to school performance relative to city average)', showlegend = True, mapbox=dict( accesstoken=mapbox_access_token, bearing=25, style='light', center=dict( lat=40.705005, lon=-73.93879 ), pitch=20, zoom=11.5, ), ) fig = dict( data=schools, layout=layout) py.iplot( fig, validate=False, filename='bubble-map-nyc-schools')
I tried adding “<a href” text to the marker itself, but it won’t translate to a clickable hyperlink.
The Plotly community appears to suggest Click Events as a solution, but I’m not sure how to combine the code in the example with my code above. I’m also not sure how to make a Click Event a hyperlink, so that clicking on a marker (school) will result in opening a new website or new tab.
Does anyone know a workaround for having clickable markers on a scattermapbox?