Skip to content

fix 212 #234

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

Merged
merged 1 commit into from
Nov 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
keyword argument will enable conversion to GeoJSON.
reset: boolean, default False
Remove all current geoJSON layers, start with new layer
freescale: if True use free format for the scale, where min and max values
are taken from the data. It also allow to plot allow to plot values < 0
and float legend labels.
freescale: if True use free format for the scale, where min and max
values are taken from the data. It also allow to plot
values < 0 and float legend labels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's a typo here, isn't it ?
you may keep the indent, and avoid the duplication of allow to plot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Urgh! My pep8 stupid mindset attacks again.

Output
------
Expand Down Expand Up @@ -893,7 +893,7 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,

# D3 Color scale.
series = data[columns[1]]
if freescale == False:
if not freescale:
if threshold_scale and len(threshold_scale) > 6:
raise ValueError
domain = threshold_scale or utilities.split_six(series=series)
Expand All @@ -918,18 +918,15 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,

if not freescale:
legend = leg_templ.render({'lin_min': 0,
'lin_max': int(domain[-1]*1.1),
'tick_labels': tick_labels,
'caption': name})


'lin_max': int(domain[-1]*1.1),
'tick_labels': tick_labels,
'caption': name})
else:
legend = leg_templ.render({'lin_min': domain[0],
'lin_max': domain[-1],
'tick_labels': tick_labels,
'caption': name})


self.template_vars.setdefault('map_legends', []).append(legend)

# Style with color brewer colors.
Expand Down Expand Up @@ -1112,14 +1109,20 @@ def create_map(self, path='map.html', plugin_data_out=True, template=None):
def _repr_html_(self):
"""Build the HTML representation for IPython."""
self._build_map() # Using the default templates.
srcdoc = self.HTML
html = self.HTML.encode('utf8')

if self.json_data:
callback = 'function(callback){{callback(null, JSON.parse({}))}}'
for path, data in self.json_data.items():
json_data = json.dumps(data).replace('"', '&quot;')
srcdoc = srcdoc.replace('d3.json, {}'.format(repr(path)),
callback.format((repr(json_data))))
srcdoc = srcdoc.replace('"', '&quot;')
return ('<iframe srcdoc="{srcdoc}" style="width: 100%; height: 500px; '
'border: none"></iframe>'.format(srcdoc=srcdoc))
json_data = json.dumps(data)
html = html.replace('d3.json, {}'.format(repr(path)),
callback.format((repr(json_data))))
html = html.replace('"', '&quot;')
iframe = ('<iframe srcdoc="{}" width=100%; height=500px; '
'border: none"></iframe>').format
else:
encoded = base64.b64encode(html)
html = "data:text/html;base64," + encoded.decode('utf8')
iframe = ('<iframe src="{}" width=100%; height=500px; '
'border: none"></iframe>').format
return iframe(html)