GeoView : correction when no places with coordinates in the database.

svn: r11739
This commit is contained in:
Serge Noiraud
2009-01-26 22:30:13 +00:00
parent a9ca12e309
commit 4cd77671bd

View File

@@ -96,6 +96,7 @@ if WebKit == NOWEB :
Config.set(Config.GEOVIEW, False) Config.set(Config.GEOVIEW, False)
raise ImportError, 'No GTK html plugin found' raise ImportError, 'No GTK html plugin found'
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Gramps Modules # Gramps Modules
@@ -115,6 +116,7 @@ MOZEMBED_SUBPATH = Utils.get_empty_tempdir('mozembed_gramps')
GEOVIEW_SUBPATH = Utils.get_empty_tempdir('geoview') GEOVIEW_SUBPATH = Utils.get_empty_tempdir('geoview')
NB_MARKERS_PER_PAGE = 200 NB_MARKERS_PER_PAGE = 200
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Renderer # Renderer
@@ -167,7 +169,6 @@ class Renderer():
""" """
raise NotImplementedError raise NotImplementedError
#def page_loaded(self,obj,status):
def page_loaded(self): def page_loaded(self):
raise NotImplementedError raise NotImplementedError
@@ -177,6 +178,7 @@ class Renderer():
""" """
self.fct() self.fct()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Renderer with WebKit # Renderer with WebKit
@@ -284,6 +286,7 @@ class RendererMozilla(Renderer):
pass pass
pass # We don't use a proxy or the http_proxy variable is not set. pass # We don't use a proxy or the http_proxy variable is not set.
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# HtmlView # HtmlView
@@ -654,7 +657,6 @@ class GeoView(HtmlView):
callback=self.event_places, callback=self.event_places,
tip=_("Attempt to view places on the Map for all events.")) tip=_("Attempt to view places on the Map for all events."))
def goto_active_person(self,handle=None): def goto_active_person(self,handle=None):
self.geo_places(self.displaytype) self.geo_places(self.displaytype)
@@ -890,7 +892,7 @@ class GeoView(HtmlView):
pass pass
# Select the center of the map and the zoom # Select the center of the map and the zoom
self.centered = False self.centered = False
if type == 2: if type == 2:
# Sort by year for events # Sort by year for events
self.sort = sorted(self.place_list, key=operator.itemgetter(7)) self.sort = sorted(self.place_list, key=operator.itemgetter(7))
else: else:
@@ -973,8 +975,8 @@ class GeoView(HtmlView):
# We center the map on a point at the center of all markers # We center the map on a point at the center of all markers
self.centerlat = maxlat/2 self.centerlat = maxlat/2
self.centerlon = maxlong/2 self.centerlon = maxlong/2
latit = self.centerlat latit = 0.0
longt = self.centerlon longt = 0.0
for mark in self.sort: for mark in self.sort:
cent = int(mark[6]) cent = int(mark[6])
if cent: if cent:
@@ -991,9 +993,11 @@ class GeoView(HtmlView):
longt = self.maxlon+self.centerlon longt = self.maxlon+self.centerlon
else: else:
longt = self.maxlon-self.centerlon longt = self.maxlon-self.centerlon
self.latit = latit self.mustcenter = False
self.longt = longt if latit != 0.0 or longt != 0.0:
self.mustcenter = True self.latit = latit
self.longt = longt
self.mustcenter = True
for page in range(0,pages,1): for page in range(0,pages,1):
self.nbpages += 1 self.nbpages += 1
if type == 1: if type == 1:
@@ -1163,40 +1167,40 @@ class GeoView(HtmlView):
self.yearinmarker = [] self.yearinmarker = []
self.mapview.write("mapstraction.addMarker(my_marker);") self.mapview.write("mapstraction.addMarker(my_marker);")
self.setattr = False self.setattr = False
if not self.centered: if self.nbmarkers > 0:
# We have no valid geographic point to center the map. if self.setattr:
# So you'll see the street where I live. years = ""
# I think another place should be better : if mark[2]:
# Where is the place where the gramps project began ? for y in self.yearinmarker:
# years += "%d " % y
# I think we should put here all gramps developpers. years += "end"
# not only me ... self.mapview.write("my_marker.setAttribute('year','%s');" % years)
# self.yearinmarker = []
longitude = -1.568792 years=""
latitude = 47.257971 self.mapview.write("mapstraction.addMarker(my_marker);")
self.mapview.write("\nvar point = new LatLonPoint(%s,%s);\n"%(latitude,longitude))
self.mapview.write(" mapstraction.setCenterAndZoom(point, %d);\n"%2)
self.mapview.write(" my_marker = new Marker(point);\n")
self.mapview.write(" my_marker.setLabel(\"%s\");\n"%_("The author of this module."))
self.mapview.write(" my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >")
self.mapview.write("Serge Noiraud<br>Nantes, France<br>")
self.mapview.write("%s</div>\");\n"%_("This request has no geolocation associated."))
self.mapview.write(" mapstraction.addMarker(my_marker);")
self.setattr = False self.setattr = False
if self.setattr: else:
years = "" # We have no valid geographic point to center the map.
if mark[2]: # So you'll see the street where I live.
for y in self.yearinmarker: # I think another place should be better :
years += "%d " % y # Where is the place where the gramps project began ?
years += "end" #
self.mapview.write("my_marker.setAttribute('year','%s');" % years) # I think we should put here all gramps developpers.
self.yearinmarker = [] # not only me ...
years="" #
self.mapview.write("mapstraction.addMarker(my_marker);") longitude = -1.568792
latitude = 47.257971
self.mapview.write("\nvar point = new LatLonPoint(%s,%s);\n"%(latitude,longitude))
self.mapview.write(" mapstraction.setCenterAndZoom(point, %d);\n"%2)
self.mapview.write(" my_marker = new Marker(point);\n")
self.mapview.write(" my_marker.setLabel(\"%s\");\n"%_("The author of this module."))
self.mapview.write(" my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >")
self.mapview.write("Serge Noiraud<br>Nantes, France<br>")
self.mapview.write("%s</div>\");\n"%_("This request has no geolocation associated."))
self.mapview.write(" mapstraction.addMarker(my_marker);")
self.setattr = False self.setattr = False
self.mapview.write("\n </script>\n") self.mapview.write("\n </script>\n")
def createPersonMarkers(self,db,person,comment): def createPersonMarkers(self,db,person,comment):
""" """
This function create all markers for the specified person. This function create all markers for the specified person.