folium:: make GeoJson search marker transparentHow can I make a time delay in Python?How to make a chain of function decorators?How to make a flat list out of list of listsplot Latitude longitude points from dataframe on folium map - iPythonPlotting markers on a map using Pandas & FoliumIs there a way to plot many markers in Folium?MongoDB GeoJSON and GoogleMap - reversed longlatExponential coordinate notation in Open Layers GeoJsonloading geojson into Mapbox object not validAdding markers to a Folium Map
What is the name of meteoroids which hit Moon, Mars, or pretty much anything that isn’t the Earth?
What does this quote in Small Gods refer to?
Is it nonsense to say B -> [A -> B]?
Why did God specifically target the firstborn in the 10th plague (Exodus 12:29-36)?
What does the act of cursing involve?
Would encrypting a database protect against a compromised admin account?
Examples where existence is harder than evaluation
Why use steam instead of just hot air?
Was there a contingency plan in place if Little Boy failed to detonate?
Text crossing the margin in amsbook
Company stopped paying my salary. What are my options?
How to find proper phrasal verbs or idioms for the sentence you're translating?
Why do unstable nuclei form?
Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech
How to slow yourself down (for playing nice with others)
Noob at soldering, can anyone explain why my circuit won't work?
Summarise to return the length by group
What was the plan for an abort of the Enola Gay's mission to drop the atomic bomb?
What are some possible reasons that a father's name is missing from a birth certificate - England?
Why is PerfectForwardSecrecy considered OK, when it has same defects as salt-less password hashing?
The meaning of a て-form verb at the end of this sentence
Can more than one creature benefit from multiple Hunter's Mark spells cast on the same target?
Remove color cast in darktable?
A Cunning Riley Riddle
folium:: make GeoJson search marker transparent
How can I make a time delay in Python?How to make a chain of function decorators?How to make a flat list out of list of listsplot Latitude longitude points from dataframe on folium map - iPythonPlotting markers on a map using Pandas & FoliumIs there a way to plot many markers in Folium?MongoDB GeoJSON and GoogleMap - reversed longlatExponential coordinate notation in Open Layers GeoJsonloading geojson into Mapbox object not validAdding markers to a Folium Map
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a basic folium heatmap that shows locations as CircleMarker and a HeatMap layer on top as displayed below.
I wanted to add search functionality in my map so I converted my pandas dataframe into a GeoJson format so that I can pass that.
class folium.plugins.Search(layer, search_label=None,
search_zoom=None, geom_type='Point', position='topleft',
placeholder='Search', collapsed=False, **kwargs) Bases:
branca.element.MacroElement
Adds a search tool to your map.
Parameters: layer (GeoJson, TopoJson, FeatureGroup, MarkerCluster
class object.) – The map layer to index in the
I was able to convert my Pandas DataFrame into GeoJson using below code.
df_json = pd.read_csv("C:\py\folium\NE Task 1\json.csv").dropna(how="any")
# convert lat-long to floats and change address from ALL CAPS to Regular Capitalization
df_json['latitude'] = df_json['latitude'].astype(float)
df_json['longitude'] = df_json['longitude'].astype(float)
df_json['Site Name'] = df_json['Site Name'].str.title()
# we don't need all those columns - only keep useful ones
useful_cols = ['Site ID', 'Site Name', 'latitude', 'longitude']
df_subset = df_json[useful_cols]
# drop any rows that lack lat/long data
df_geo = df_subset.dropna(subset=['latitude', 'longitude'], axis=0, inplace=False)
def df_to_geojson(df_json, properties, lat='latitude', lon='longitude'):
geojson = 'type': 'FeatureCollection', 'features': []
# loop through each row in the dataframe and convert each row to geojson format
for _, row in df_json.iterrows():
# create a feature template to fill in
feature = 'type': 'Feature',
'properties': ,
'geometry': 'type': 'Point', 'coordinates': []
# fill in the coordinates
feature['geometry']['coordinates'] = [row[lon], row[lat]]
# for each column, get the value and add it as a new feature property
for prop in properties:
feature['properties'][prop] = row[prop]
# add this feature (aka, converted dataframe row) to the list of features inside our dict
geojson['features'].append(feature)
return geojson
geojson_dict = df_to_geojson(df_geo, properties=useful_cols)
geojson_str = json.dumps(geojson_dict, indent=2)
folium.plugins.Search(data=geojson_dict, geom_type='Point',
search_zoom=14, search_label='Site ID').add_to(map)
After doing that search function is working properly as i wanted but a Marker is being displayed on TOP which i cannot hide like below.
Please help me guide how can I hide this marker and keep GeoJson intact so that I can use it for search function. I tried to make it transparent, change the opacity of GeoJson through the solutions I found over stackOverflow but nothing works.
Thanks in advance for your time and sorry for the long post.
Best Regards
python geojson folium
add a comment |
I have a basic folium heatmap that shows locations as CircleMarker and a HeatMap layer on top as displayed below.
I wanted to add search functionality in my map so I converted my pandas dataframe into a GeoJson format so that I can pass that.
class folium.plugins.Search(layer, search_label=None,
search_zoom=None, geom_type='Point', position='topleft',
placeholder='Search', collapsed=False, **kwargs) Bases:
branca.element.MacroElement
Adds a search tool to your map.
Parameters: layer (GeoJson, TopoJson, FeatureGroup, MarkerCluster
class object.) – The map layer to index in the
I was able to convert my Pandas DataFrame into GeoJson using below code.
df_json = pd.read_csv("C:\py\folium\NE Task 1\json.csv").dropna(how="any")
# convert lat-long to floats and change address from ALL CAPS to Regular Capitalization
df_json['latitude'] = df_json['latitude'].astype(float)
df_json['longitude'] = df_json['longitude'].astype(float)
df_json['Site Name'] = df_json['Site Name'].str.title()
# we don't need all those columns - only keep useful ones
useful_cols = ['Site ID', 'Site Name', 'latitude', 'longitude']
df_subset = df_json[useful_cols]
# drop any rows that lack lat/long data
df_geo = df_subset.dropna(subset=['latitude', 'longitude'], axis=0, inplace=False)
def df_to_geojson(df_json, properties, lat='latitude', lon='longitude'):
geojson = 'type': 'FeatureCollection', 'features': []
# loop through each row in the dataframe and convert each row to geojson format
for _, row in df_json.iterrows():
# create a feature template to fill in
feature = 'type': 'Feature',
'properties': ,
'geometry': 'type': 'Point', 'coordinates': []
# fill in the coordinates
feature['geometry']['coordinates'] = [row[lon], row[lat]]
# for each column, get the value and add it as a new feature property
for prop in properties:
feature['properties'][prop] = row[prop]
# add this feature (aka, converted dataframe row) to the list of features inside our dict
geojson['features'].append(feature)
return geojson
geojson_dict = df_to_geojson(df_geo, properties=useful_cols)
geojson_str = json.dumps(geojson_dict, indent=2)
folium.plugins.Search(data=geojson_dict, geom_type='Point',
search_zoom=14, search_label='Site ID').add_to(map)
After doing that search function is working properly as i wanted but a Marker is being displayed on TOP which i cannot hide like below.
Please help me guide how can I hide this marker and keep GeoJson intact so that I can use it for search function. I tried to make it transparent, change the opacity of GeoJson through the solutions I found over stackOverflow but nothing works.
Thanks in advance for your time and sorry for the long post.
Best Regards
python geojson folium
add a comment |
I have a basic folium heatmap that shows locations as CircleMarker and a HeatMap layer on top as displayed below.
I wanted to add search functionality in my map so I converted my pandas dataframe into a GeoJson format so that I can pass that.
class folium.plugins.Search(layer, search_label=None,
search_zoom=None, geom_type='Point', position='topleft',
placeholder='Search', collapsed=False, **kwargs) Bases:
branca.element.MacroElement
Adds a search tool to your map.
Parameters: layer (GeoJson, TopoJson, FeatureGroup, MarkerCluster
class object.) – The map layer to index in the
I was able to convert my Pandas DataFrame into GeoJson using below code.
df_json = pd.read_csv("C:\py\folium\NE Task 1\json.csv").dropna(how="any")
# convert lat-long to floats and change address from ALL CAPS to Regular Capitalization
df_json['latitude'] = df_json['latitude'].astype(float)
df_json['longitude'] = df_json['longitude'].astype(float)
df_json['Site Name'] = df_json['Site Name'].str.title()
# we don't need all those columns - only keep useful ones
useful_cols = ['Site ID', 'Site Name', 'latitude', 'longitude']
df_subset = df_json[useful_cols]
# drop any rows that lack lat/long data
df_geo = df_subset.dropna(subset=['latitude', 'longitude'], axis=0, inplace=False)
def df_to_geojson(df_json, properties, lat='latitude', lon='longitude'):
geojson = 'type': 'FeatureCollection', 'features': []
# loop through each row in the dataframe and convert each row to geojson format
for _, row in df_json.iterrows():
# create a feature template to fill in
feature = 'type': 'Feature',
'properties': ,
'geometry': 'type': 'Point', 'coordinates': []
# fill in the coordinates
feature['geometry']['coordinates'] = [row[lon], row[lat]]
# for each column, get the value and add it as a new feature property
for prop in properties:
feature['properties'][prop] = row[prop]
# add this feature (aka, converted dataframe row) to the list of features inside our dict
geojson['features'].append(feature)
return geojson
geojson_dict = df_to_geojson(df_geo, properties=useful_cols)
geojson_str = json.dumps(geojson_dict, indent=2)
folium.plugins.Search(data=geojson_dict, geom_type='Point',
search_zoom=14, search_label='Site ID').add_to(map)
After doing that search function is working properly as i wanted but a Marker is being displayed on TOP which i cannot hide like below.
Please help me guide how can I hide this marker and keep GeoJson intact so that I can use it for search function. I tried to make it transparent, change the opacity of GeoJson through the solutions I found over stackOverflow but nothing works.
Thanks in advance for your time and sorry for the long post.
Best Regards
python geojson folium
I have a basic folium heatmap that shows locations as CircleMarker and a HeatMap layer on top as displayed below.
I wanted to add search functionality in my map so I converted my pandas dataframe into a GeoJson format so that I can pass that.
class folium.plugins.Search(layer, search_label=None,
search_zoom=None, geom_type='Point', position='topleft',
placeholder='Search', collapsed=False, **kwargs) Bases:
branca.element.MacroElement
Adds a search tool to your map.
Parameters: layer (GeoJson, TopoJson, FeatureGroup, MarkerCluster
class object.) – The map layer to index in the
I was able to convert my Pandas DataFrame into GeoJson using below code.
df_json = pd.read_csv("C:\py\folium\NE Task 1\json.csv").dropna(how="any")
# convert lat-long to floats and change address from ALL CAPS to Regular Capitalization
df_json['latitude'] = df_json['latitude'].astype(float)
df_json['longitude'] = df_json['longitude'].astype(float)
df_json['Site Name'] = df_json['Site Name'].str.title()
# we don't need all those columns - only keep useful ones
useful_cols = ['Site ID', 'Site Name', 'latitude', 'longitude']
df_subset = df_json[useful_cols]
# drop any rows that lack lat/long data
df_geo = df_subset.dropna(subset=['latitude', 'longitude'], axis=0, inplace=False)
def df_to_geojson(df_json, properties, lat='latitude', lon='longitude'):
geojson = 'type': 'FeatureCollection', 'features': []
# loop through each row in the dataframe and convert each row to geojson format
for _, row in df_json.iterrows():
# create a feature template to fill in
feature = 'type': 'Feature',
'properties': ,
'geometry': 'type': 'Point', 'coordinates': []
# fill in the coordinates
feature['geometry']['coordinates'] = [row[lon], row[lat]]
# for each column, get the value and add it as a new feature property
for prop in properties:
feature['properties'][prop] = row[prop]
# add this feature (aka, converted dataframe row) to the list of features inside our dict
geojson['features'].append(feature)
return geojson
geojson_dict = df_to_geojson(df_geo, properties=useful_cols)
geojson_str = json.dumps(geojson_dict, indent=2)
folium.plugins.Search(data=geojson_dict, geom_type='Point',
search_zoom=14, search_label='Site ID').add_to(map)
After doing that search function is working properly as i wanted but a Marker is being displayed on TOP which i cannot hide like below.
Please help me guide how can I hide this marker and keep GeoJson intact so that I can use it for search function. I tried to make it transparent, change the opacity of GeoJson through the solutions I found over stackOverflow but nothing works.
Thanks in advance for your time and sorry for the long post.
Best Regards
python geojson folium
python geojson folium
asked Mar 23 at 10:28
Riz.KhanRiz.Khan
493
493
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In general,
if you add folium.LayerControl().add_to(map)
to the map then it provides functionality to display or hide your Geojson markers. Then you can hide or display markers using show=False
or from 'Layers' icon on the top right of the map (see the image below)
For example:
# creating folium GeoJson objects from out GeoDataFrames
pointgeo = folium.GeoJson(gdf,name='group on map', show=False,
tooltip=folium.GeoJsonTooltip(fields=['Name', 'Relation', 'City'], aliases=['Name','Relation', 'City'],
localize=True)).add_to(map)
# To Add a LayerControl add below line
folium.LayerControl().add_to(map)
map
Like in these images Marker are shown or hidden by controlling layer from top righ 'Layers' - 1) with markers 2) markers hidden
you can refer to this link for more example:
Folium_search
Hope this helps!!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312766%2ffolium-make-geojson-search-marker-transparent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In general,
if you add folium.LayerControl().add_to(map)
to the map then it provides functionality to display or hide your Geojson markers. Then you can hide or display markers using show=False
or from 'Layers' icon on the top right of the map (see the image below)
For example:
# creating folium GeoJson objects from out GeoDataFrames
pointgeo = folium.GeoJson(gdf,name='group on map', show=False,
tooltip=folium.GeoJsonTooltip(fields=['Name', 'Relation', 'City'], aliases=['Name','Relation', 'City'],
localize=True)).add_to(map)
# To Add a LayerControl add below line
folium.LayerControl().add_to(map)
map
Like in these images Marker are shown or hidden by controlling layer from top righ 'Layers' - 1) with markers 2) markers hidden
you can refer to this link for more example:
Folium_search
Hope this helps!!
add a comment |
In general,
if you add folium.LayerControl().add_to(map)
to the map then it provides functionality to display or hide your Geojson markers. Then you can hide or display markers using show=False
or from 'Layers' icon on the top right of the map (see the image below)
For example:
# creating folium GeoJson objects from out GeoDataFrames
pointgeo = folium.GeoJson(gdf,name='group on map', show=False,
tooltip=folium.GeoJsonTooltip(fields=['Name', 'Relation', 'City'], aliases=['Name','Relation', 'City'],
localize=True)).add_to(map)
# To Add a LayerControl add below line
folium.LayerControl().add_to(map)
map
Like in these images Marker are shown or hidden by controlling layer from top righ 'Layers' - 1) with markers 2) markers hidden
you can refer to this link for more example:
Folium_search
Hope this helps!!
add a comment |
In general,
if you add folium.LayerControl().add_to(map)
to the map then it provides functionality to display or hide your Geojson markers. Then you can hide or display markers using show=False
or from 'Layers' icon on the top right of the map (see the image below)
For example:
# creating folium GeoJson objects from out GeoDataFrames
pointgeo = folium.GeoJson(gdf,name='group on map', show=False,
tooltip=folium.GeoJsonTooltip(fields=['Name', 'Relation', 'City'], aliases=['Name','Relation', 'City'],
localize=True)).add_to(map)
# To Add a LayerControl add below line
folium.LayerControl().add_to(map)
map
Like in these images Marker are shown or hidden by controlling layer from top righ 'Layers' - 1) with markers 2) markers hidden
you can refer to this link for more example:
Folium_search
Hope this helps!!
In general,
if you add folium.LayerControl().add_to(map)
to the map then it provides functionality to display or hide your Geojson markers. Then you can hide or display markers using show=False
or from 'Layers' icon on the top right of the map (see the image below)
For example:
# creating folium GeoJson objects from out GeoDataFrames
pointgeo = folium.GeoJson(gdf,name='group on map', show=False,
tooltip=folium.GeoJsonTooltip(fields=['Name', 'Relation', 'City'], aliases=['Name','Relation', 'City'],
localize=True)).add_to(map)
# To Add a LayerControl add below line
folium.LayerControl().add_to(map)
map
Like in these images Marker are shown or hidden by controlling layer from top righ 'Layers' - 1) with markers 2) markers hidden
you can refer to this link for more example:
Folium_search
Hope this helps!!
answered May 1 at 10:47
Vineet SansiVineet Sansi
447
447
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312766%2ffolium-make-geojson-search-marker-transparent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown