display tree name and center the maps on marker click

This commit is contained in:
Daniel afx 2020-10-16 03:12:15 +03:00
parent 7f9fb5e3be
commit 5585f790a7
9 changed files with 28 additions and 18 deletions

Binary file not shown.

View file

@ -26,8 +26,8 @@ def iterate_kml(filepath):
yield {
"FMID": autoincrement,
"MarketName": name,
"Website": "https://deflax.net",
"Facebook": "https://facebook.com/page",
"Website": "web_url",
"Facebook": "fb_page_id",
"Twitter": "tw_user",
"Youtube": "yt_user",
"OtherMedia": "om_user",

View file

@ -7,7 +7,8 @@
lat: 42.131331
lon: 24.747571
zoom: 17
snap_to_zoom: False
snap_to_zoom: True
pause_on_action: True
on_zoom:
#self.zoom = 10 if self.zoom < 10 else self.zoom
#self.print_current_zoom(self.zoom)

View file

@ -1,6 +1,6 @@
from kivy_garden.mapview import MapView
from kivy.clock import Clock
from kivy.app import App
from kivy.clock import Clock
from kivy_garden.mapview import MapView
from treemarker import TreeMarker
@ -34,7 +34,7 @@ class ForestMapView(MapView):
trees = app.cursor.fetchall()
for tree in trees:
name = tree[0]
print("] Fountain detected: " + str(tree))
#print("] Fountain detected: " + str(tree))
if name in self.tree_names:
continue
else:

View file

@ -191,6 +191,11 @@ Builder.load_string(
size: self.size
Color:
rgba: [1,0,0,.5]
ThinBox:
ThinLabel:
text: "Name: "
ThinLabelButton:
text: root.MarketName
ThinBox:
ThinLabel:
text: "Address: "
@ -598,7 +603,7 @@ class BaseDialog(ThemableBehavior, ModalView):
)
class ListMDDialog(BaseDialog):
name = StringProperty("Missing data")
MarketName = StringProperty("Missing data")
address = StringProperty("Missing data")
Website = StringProperty("Missing data")
Facebook = StringProperty("Missing data")

View file

@ -2,9 +2,5 @@
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: "Global Forest"
right_action_items: [['magnify', lambda x: app.search_menu.open()]]
md_bg_color: app.theme_cls.primary_color
ForestMapView:
id: forestmapview

View file

@ -17,7 +17,7 @@ from kivy.graphics import Rectangle
# Import local modules
from forestmapview import ForestMapView
from searchpopupmenu import SearchPopupMenu
#from searchpopupmenu import SearchPopupMenu
from gpshelper import GpsHelper
from settings import SampleBoxLayout
from game import GameWidget
@ -76,7 +76,7 @@ class MainApp(MDApp):
self.cursor = self.connection.cursor()
# Instantiate SearchPopupMenu
self.search_menu = SearchPopupMenu()
#self.search_menu = SearchPopupMenu()
if __name__ == '__main__':
#screen_manager = ScreenManager()

View file

@ -1,11 +1,21 @@
from kivy.app import App
from kivy.clock import Clock
from kivy_garden.mapview import MapMarkerPopup
from treepopupmenu import TreePopupMenu
class TreeMarker(MapMarkerPopup):
tree_data = []
def on_release(self):
# Center the map first
forestmap = App.get_running_app().root.ids.forestmapview
forestmap.center_on(self.lat, self.lon)
# Open the TreePopupMenu
menu = TreePopupMenu(self.tree_data)
menu.size_hint = [.8, .9]
menu.open()
Clock.schedule_once(menu.open, 1)
def update_forestmap_position(self):
print("] New Forest Map POSITION", self.lat, self.lon)

View file

@ -4,16 +4,14 @@ class TreePopupMenu(ListMDDialog):
def __init__(self, tree_data):
super().__init__()
print("] Selected tree data: " + str(tree_data))
#print("] Selected tree data: " + str(tree_data))
# Set all of the fields of tree data
#headers = "Name,Lat,Lon,Description"
headers = "FMID,MarketName,Website,Facebook,Twitter,Youtube,OtherMedia,street,city,County,State,zip,Season1Date,Season1Time,Season2Date,Season2Time,Season3Date,Season3Time,Season4Date,Season4Time,x,y,Location,Credit,WIC,WICcash,SFMNP,SNAP,Organic,Bakedgoods,Cheese,Crafts,Flowers,Eggs,Seafood,Herbs,Vegetables,Honey,Jams,Maple,Meat,Nursery,Nuts,Plants,Poultry,Prepared,Soap,Trees,Wine,Coffee,Beans,Fruits,Grains,Juices,Mushrooms,PetFood,Tofu,WildHarvested,updateTime"
headers = headers.split(',')
for i in range(len(headers)):
attribute_name = headers[i]
#print("attr name " + str(attribute_name))
attribute_value = tree_data[i]
#print("attr value " + str(attribute_value))
#print("] " + str(attribute_name) + " = " + str(attribute_value))
setattr(self, attribute_name, attribute_value)