Skip to content

Revert a0fc55d6822b5fb2e8430809c2e98f38d257efe3 #237

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 4, 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: 17 additions & 20 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
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 allow to plot values < 0
and float legend labels.

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 not freescale:
if freescale == False:
if threshold_scale and len(threshold_scale) > 6:
raise ValueError
domain = threshold_scale or utilities.split_six(series=series)
Expand All @@ -918,15 +918,18 @@ 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 @@ -1109,20 +1112,14 @@ 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.
html = self.HTML.encode('utf8')
srcdoc = self.HTML

if self.json_data:
callback = 'function(callback){{callback(null, JSON.parse({}))}}'
for path, data in self.json_data.items():
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)
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))