Customized map for real Estate
The following is a customized map that i made for lindohomes.mx. First you need to make a list in excel of the places you want to put on the map, i will give a example list below, you will see in the example image what kind of data you need in excel. If you want to customize the code with different icons or colors for the markers i will leave a link where you can download the code to customize the map. Run the python script and it will generate the map. Then all that you have to do, is put it on your website. Keep in mind you can customize this map for anything, not just realestate.
I have used openstreetmap api because this way you don’t need to use a google api key. The only problem is that openstreetmap doesn’t have a satelite layer meaning that there is no satelite view on their maps, but there is a workaround! You can overlay a satellite layer from a different source and change the opacity so you can see the street names and the satellite view. There are free sources out in the net that provide free satellite tiles you can use. I used the arcgis tile. This took me almost an entire day to get the settings just right, alot of trial and error. I will leave the code here and in my github so you can download. If you want me to create a custom map for you, email me at pointperks@gmail.com. If you do use my code for your own personal or commercial use, just provide attributions please, this stuff takes alot of hard work. This code is under Attribution 4.0 International (CC BY 4.0) https://creativecommons.org/licenses/by/4.0/ . If you feel like donating for my efforts i will leave these links below. This code is written in python. Also i added a function so you can drive directly to where your markers are. Enjoy! https://github.com/salvecom333/custom_map_creator This is where you can download the code.
import folium
import pandas as pd
import tkinter.filedialog as fd
import os
root = fd.Tk()
root.withdraw() # use to hide tkinter window
currdir = os.getcwd()
input_file_path = fd.askopenfilename(parent=root, initialdir=currdir, title='Please select an input file')
if len(input_file_path) > 0:
print("You chose %s" % input_file_path)
data = pd.read_excel(input_file_path)
# Create a Folium map centered on the mean latitude and longitude
center_lat = data['Latitude'].mean()
center_lon = data['Longitude'].mean()
m = folium.Map(location=[center_lat, center_lon], zoom_start=16, control_scale=True)
# Add satellite imagery as a TileLayer
folium.TileLayer(
tiles='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
attr='ArcGIS',
name='Satellite Imagery',
opacity=1,
overlay=True
).add_to(m)
# Add OpenStreetMap overlay with increased opacity for street names
folium.TileLayer(
tiles='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attr='OpenStreetMap Overlay',
name='Street Names',
overlay=True,
opacity=0.5, # Increase the opacity to make the street names more opaque
).add_to(m)
# Create a layer control
folium.LayerControl().add_to(m)
# Iterate over the rows of the data table
for index, row in data.iterrows():
# Extract the required information from the row
location = [row['Latitude'], row['Longitude']]
type = row['Type']
price = row['Price']
lot_t = row['Lot type']
w_and_p = row['Water&Power']
a_l = row['Adjacent Lot']
popup_text = f'Type: {type}<br>Lot type: {lot_t}<br>Price: {price}<br>Water&Power: {w_and_p}<br>Adjacent Lot: {a_l}'
popup_html = folium.Html(popup_text, script=True)
popup = folium.Popup(popup_html, max_width=1000)
# Create a marker with a popup for each location
icon = folium.Icon(icon='sign-hanging fa-bounce', prefix='fa', color='red')
folium.Marker(location=location, icon=icon, popup=popup).add_to(m)
# Save the map to an HTML file
output_file_path = fd.asksaveasfilename(parent=root, initialdir=currdir, title='Please select an output file',
defaultextension='.html', filetypes=[('HTML files', '.html')])
if len(output_file_path) > 0:
m.save(output_file_path)
print("Map saved to %s" % output_file_path)