def FillMap(self): coordinatesDict = defaultdict() coordinatesDict[self.location] = self.coordinates mapWidth = self.width() - 40 mapHeight = self.height() - 170 thisMap = code_MapHtml.MapHtml() thisMap.mapHeight = mapHeight thisMap.mapWidth = mapWidth thisMap.coordinatesDict = coordinatesDict html = thisMap.html() self.webMap.setHtml(html)
def FillMap(self): coordinatesDict = defaultdict() mapWidth = self.width() - 20 mapHeight = self.height() - self.lblLocation.height() - ( self.lblDateRange.height() * 7.5) self.webMap.setGeometry(5, 5, mapWidth, mapHeight) for l in range(self.lstLocations.count()): locationName = self.lstLocations.item(l).text() coordinates = self.mdiParent.db.GetLocationCoordinates( locationName) coordinatesDict[locationName] = coordinates thisMap = code_MapHtml.MapHtml() thisMap.mapHeight = mapHeight - 20 thisMap.mapWidth = mapWidth - 20 thisMap.coordinatesDict = coordinatesDict # save mapHtml in object's variable so we can reload it later self.mapHtml = thisMap.html() # pass the mapHtml we created to the QWebView widget for display self.webMap.setHtml(self.mapHtml)
def LoadLocationsMap(self, filter): self.title = "Location Map" coordinatesDict = defaultdict() mapWidth = self.frameGeometry().width() - 10 mapHeight = self.frameGeometry().height() - 35 self.scrollArea.setGeometry(5, 27, mapWidth + 2, mapHeight + 2) self.webView.setGeometry(5, 27, mapWidth + 2, mapHeight + 2) self.contentType = "Map" self.filter = filter locations = self.mdiParent.db.GetLocations(filter) if len(locations) == 0: return (False) for l in locations: coordinates = self.mdiParent.db.GetLocationCoordinates(l) coordinatesDict[l] = coordinates thisMap = code_MapHtml.MapHtml() thisMap.mapHeight = mapHeight thisMap.mapWidth = mapWidth thisMap.coordinatesDict = coordinatesDict html = thisMap.html() self.webView.setHtml(html) # set window title to descriptive map name locationName = filter.getLocationName( ) # str name of region or location or "" locationType = filter.getLocationType() startDate = filter.getStartDate() # str format yyyy-mm-dd or "" endDate = filter.getEndDate() # str format yyyy-mm-dd or "" startSeasonalMonth = filter.getStartSeasonalMonth() # str format mm startSeasonalDay = filter.getStartSeasonalDay() # str format dd endSeasonalMonth = filter.getEndSeasonalMonth() # str format dd endSeasonalDay = filter.getEndSeasonalDay() # str format dd speciesName = filter.getSpeciesName() # str speciesName family = filter.getFamily() # str family name # set main location label, using "All Locations" if none others are selected windowTitle = speciesName if locationName != "": if locationType == "Country": locationName = self.mdiParent.db.GetCountryName(locationName) if locationType == "State": locationName = self.mdiParent.db.GetStateName(locationName) windowTitle = windowTitle + "; " + locationName if startDate != "": dateTitle = startDate + " to " + endDate if startDate == endDate: dateTitle = startDate windowTitle = windowTitle + "; " + dateTitle # set main seasonal range label, if specified if not ((startSeasonalMonth == "") or (endSeasonalMonth == "")): monthRange = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] rangeTitle = monthRange[ int(startSeasonalMonth) - 1] + "-" + startSeasonalDay + " to " + monthRange[ int(endSeasonalMonth) - 1] + "-" + endSeasonalDay windowTitle = windowTitle + "; " + rangeTitle if family != "": family = family[0:family.index("(") - 1] windowTitle = windowTitle + "; " + family if windowTitle == "": windowTitle = "All species, locations, dates and families" #remove leading "; " if needed if windowTitle[0:2] == "; ": windowTitle = windowTitle[2:] # add location count to window title windowTitle = "Map: " + windowTitle + " (" + str( len(coordinatesDict.keys())) + ")" self.setWindowTitle(windowTitle) self.title = windowTitle icon = QIcon() icon.addPixmap(QPixmap(":/icon_map.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) return (True)