GeoView : javascript optimization ( size, comments )
add a popup and limit the number of markers. svn: r11613
This commit is contained in:
parent
3785b8e74e
commit
36b0181ed1
@ -208,7 +208,6 @@ class RendererMozilla(Renderer):
|
|||||||
set_profile_path(MOZEMBED_PATH, MOZEMBED_SUBPATH)
|
set_profile_path(MOZEMBED_PATH, MOZEMBED_SUBPATH)
|
||||||
self.__set_mozembed_proxy()
|
self.__set_mozembed_proxy()
|
||||||
self.window = gtkmozembed.MozEmbed()
|
self.window = gtkmozembed.MozEmbed()
|
||||||
#self.window.set_size_request(800, 600)
|
|
||||||
self.browser = MOZIL
|
self.browser = MOZIL
|
||||||
|
|
||||||
def open(self, url):
|
def open(self, url):
|
||||||
@ -1012,27 +1011,32 @@ class GeoView(HtmlView):
|
|||||||
self.mustcenter = False
|
self.mustcenter = False
|
||||||
yearinmarker = []
|
yearinmarker = []
|
||||||
for mark in sort:
|
for mark in sort:
|
||||||
|
if indm > 1000:
|
||||||
|
from QuestionDialog import WarningDialog
|
||||||
|
WarningDialog(
|
||||||
|
_('Be careful: You have more than 1000 markers!'),
|
||||||
|
_("This means it could take a while to see the map on the HtmlView.\n"
|
||||||
|
"This functionality use 100% of cpu during this phase."
|
||||||
|
"A high cpu temperature could power off the machine.\n"
|
||||||
|
))
|
||||||
|
break
|
||||||
if last != mark[0]:
|
if last != mark[0]:
|
||||||
years=""
|
years=""
|
||||||
if last != "":
|
if last != "":
|
||||||
self.mapview.write("</div>\");\n")
|
self.mapview.write("</div>\");")
|
||||||
if mark[2]:
|
if mark[2]:
|
||||||
for y in yearinmarker:
|
for y in yearinmarker:
|
||||||
years += "%d " % y
|
years += "%d " % y
|
||||||
years += "end"
|
years += "end"
|
||||||
self.mapview.write(" my_marker.setAttribute('year','%s');\n" % years)
|
self.mapview.write("my_marker.setAttribute('year','%s');" % years)
|
||||||
yearinmarker = []
|
yearinmarker = []
|
||||||
years=""
|
years=""
|
||||||
self.mapview.write("mapstraction.addMarker(my_marker);\n")
|
self.mapview.write("mapstraction.addMarker(my_marker);\n")
|
||||||
if self.mustcenter:
|
if self.mustcenter:
|
||||||
self.centered = 1
|
self.centered = 1
|
||||||
self.mapview.write(" var point = new LatLonPoint(%s,%s);\n"%(latit,longt))
|
self.mapview.write("var point = new LatLonPoint(%s,%s);"%(latit,longt))
|
||||||
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
||||||
self.mustcenter = False
|
self.mustcenter = False
|
||||||
if mark[2]:
|
|
||||||
self.mapview.write(" // map locations for %s;\n"%mark[1])
|
|
||||||
else:
|
|
||||||
self.mapview.write(" // map locations for %s;\n"%mark[0])
|
|
||||||
last = mark[0]
|
last = mark[0]
|
||||||
cent=int(mark[6])
|
cent=int(mark[6])
|
||||||
if (cent == 1):
|
if (cent == 1):
|
||||||
@ -1058,13 +1062,13 @@ class GeoView(HtmlView):
|
|||||||
|
|
||||||
LOG.debug("latitude centree = %s\n" % latit)
|
LOG.debug("latitude centree = %s\n" % latit)
|
||||||
LOG.debug("longitude centree = %s\n" % longt)
|
LOG.debug("longitude centree = %s\n" % longt)
|
||||||
self.mapview.write(" var point = new LatLonPoint(%s,%s);\n"%(latit,longt))
|
self.mapview.write("var point = new LatLonPoint(%s,%s);"%(latit,longt))
|
||||||
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
||||||
self.mapview.write(" var point = new LatLonPoint(%s,%s);\n"%(mark[3],mark[4]))
|
self.mapview.write("var point = new LatLonPoint(%s,%s);"%(mark[3],mark[4]))
|
||||||
self.mapview.write(" my_marker = new Marker(point);\n")
|
self.mapview.write("my_marker = new Marker(point);")
|
||||||
self.mapview.write(" gmarkers[%d]=my_marker;\n" % indm)
|
self.mapview.write("gmarkers[%d]=my_marker;" % indm)
|
||||||
indm+=1;
|
indm+=1;
|
||||||
self.mapview.write(" my_marker.setLabel(\"%s\");\n"%mark[0])
|
self.mapview.write("my_marker.setLabel(\"%s\");"%mark[0])
|
||||||
yearinmarker.append(mark[7])
|
yearinmarker.append(mark[7])
|
||||||
divclose=0
|
divclose=0
|
||||||
self.mapview.write("my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >")
|
self.mapview.write("my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >")
|
||||||
@ -1112,19 +1116,20 @@ class GeoView(HtmlView):
|
|||||||
longt = str(float(mark[4])+centerlon)
|
longt = str(float(mark[4])+centerlon)
|
||||||
LOG.debug("longt 4 1")
|
LOG.debug("longt 4 1")
|
||||||
self.mustcenter = True
|
self.mustcenter = True
|
||||||
|
|
||||||
if divclose == 0:
|
if divclose == 0:
|
||||||
self.mapview.write("</div>\");\n")
|
self.mapview.write("</div>\");")
|
||||||
if mark[2]:
|
if mark[2]:
|
||||||
for y in yearinmarker:
|
for y in yearinmarker:
|
||||||
years += "%d " % y
|
years += "%d " % y
|
||||||
years += "end"
|
years += "end"
|
||||||
self.mapview.write(" my_marker.setAttribute('year','%s');\n" % years)
|
self.mapview.write("my_marker.setAttribute('year','%s');" % years)
|
||||||
yearinmarker = []
|
yearinmarker = []
|
||||||
years=""
|
years=""
|
||||||
self.mapview.write(" mapstraction.addMarker(my_marker);\n")
|
self.mapview.write("mapstraction.addMarker(my_marker);")
|
||||||
if self.mustcenter:
|
if self.mustcenter:
|
||||||
self.centered = 1
|
self.centered = 1
|
||||||
self.mapview.write(" var point = new LatLonPoint(%s,%s);\n"%(self.latit,self.longt))
|
self.mapview.write("var point = new LatLonPoint(%s,%s);"%(self.latit,self.longt))
|
||||||
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
self.mapview.write("mapstraction.setCenterAndZoom(point, %s);\n"%self.zoom)
|
||||||
if ( self.centered == 0 ):
|
if ( self.centered == 0 ):
|
||||||
# We have no valid geographic point to center the map.
|
# We have no valid geographic point to center the map.
|
||||||
@ -1218,9 +1223,6 @@ class GeoView(HtmlView):
|
|||||||
|
|
||||||
latitude = ""
|
latitude = ""
|
||||||
longitude = ""
|
longitude = ""
|
||||||
person = db.db.get_default_person()
|
|
||||||
if not person:
|
|
||||||
person = db.active
|
|
||||||
self.center = 1
|
self.center = 1
|
||||||
for place_handle in db.db.get_place_handles():
|
for place_handle in db.db.get_place_handles():
|
||||||
place = db.db.get_place_from_handle( place_handle)
|
place = db.db.get_place_from_handle( place_handle)
|
||||||
@ -1234,7 +1236,7 @@ class GeoView(HtmlView):
|
|||||||
country = place.get_main_location().get_country()
|
country = place.get_main_location().get_country()
|
||||||
if ( cmp(longitude,"") == 1 | cmp(latitude,"") == 1 ):
|
if ( cmp(longitude,"") == 1 | cmp(latitude,"") == 1 ):
|
||||||
self.append_to_places_list(descr, None,
|
self.append_to_places_list(descr, None,
|
||||||
_nd.display(person),
|
"",
|
||||||
latitude, longitude,
|
latitude, longitude,
|
||||||
descr1, self.center, None)
|
descr1, self.center, None)
|
||||||
self.center = 0
|
self.center = 0
|
||||||
@ -1259,9 +1261,6 @@ class GeoView(HtmlView):
|
|||||||
|
|
||||||
latitude = ""
|
latitude = ""
|
||||||
longitude = ""
|
longitude = ""
|
||||||
person = db.db.get_default_person()
|
|
||||||
if not person:
|
|
||||||
person = db.active
|
|
||||||
self.center = 1
|
self.center = 1
|
||||||
for event_handle in db.db.get_event_handles():
|
for event_handle in db.db.get_event_handles():
|
||||||
event = db.db.get_event_from_handle( event_handle)
|
event = db.db.get_event_from_handle( event_handle)
|
||||||
|
Loading…
Reference in New Issue
Block a user