def loadkml(self, filename):
        '''Load a kml from file and put it on the map'''
        #Open the zip file
        nodes = self.readkmz(filename)

        self.snap_points = []

        #go through each object in the kml...
        for n in nodes:     
            point = self.readObject(n)

            #and place any polygons on the map
            if self.mpstate.map is not None and point[0] == 'Polygon':
                self.snap_points.extend(point[2])

                #print("Adding " + point[1])
                newcolour = (random.randint(0, 255), 0, random.randint(0, 255))
                curpoly = mp_slipmap.SlipPolygon(point[1], point[2],
                                                             layer=2, linewidth=2, colour=newcolour)
                self.mpstate.map.add_object(curpoly)
                self.allayers.append(curpoly)
                self.curlayers.append(point[1])
                
                
            #and points - barrell image and text
            if self.mpstate.map is not None and point[0] == 'Point':
                #print("Adding " + point[1])
                icon = self.mpstate.map.icon('barrell.png')
                curpoint = mp_slipmap.SlipIcon(point[1], latlon = (point[2][0][0], point[2][0][1]), layer=3, img=icon, rotation=0, follow=False)
                curtext = mp_slipmap.SlipLabel(point[1], point = (point[2][0][0], point[2][0][1]), layer=4, label=point[1], colour=(0,255,255))
                self.mpstate.map.add_object(curpoint)
                self.mpstate.map.add_object(curtext)
                self.allayers.append(curpoint)
                self.alltextlayers.append(curtext)
                self.curlayers.append(point[1])
                self.curtextlayers.append(point[1])
        self.menu_needs_refreshing = True
def loadkml ( self , filename ) : nodes = self . readkmz ( filename ) self . snap_points = [ ] for n in nodes : point = self . readObject ( n ) if self . mpstate . map is not None and point [ 0 ] == 'Polygon' : self . snap_points . extend ( point [ 2 ] ) newcolour = ( random . randint ( 0 , 255 ) , 0 , random . randint ( 0 , 255 ) ) curpoly = mp_slipmap . SlipPolygon ( point [ 1 ] , point [ 2 ] , layer = 2 , linewidth = 2 , colour = newcolour ) self . mpstate . map . add_object ( curpoly ) self . allayers . append ( curpoly ) self . curlayers . append ( point [ 1 ] ) if self . mpstate . map is not None and point [ 0 ] == 'Point' : icon = self . mpstate . map . icon ( 'barrell.png' ) curpoint = mp_slipmap . SlipIcon ( point [ 1 ] , latlon = ( point [ 2 ] [ 0 ] [ 0 ] , point [ 2 ] [ 0 ] [ 1 ] ) , layer = 3 , img = icon , rotation = 0 , follow = False ) curtext = mp_slipmap . SlipLabel ( point [ 1 ] , point = ( point [ 2 ] [ 0 ] [ 0 ] , point [ 2 ] [ 0 ] [ 1 ] ) , layer = 4 , label = point [ 1 ] , colour = ( 0 , 255 , 255 ) ) self . mpstate . map . add_object ( curpoint ) self . mpstate . map . add_object ( curtext ) self . allayers . append ( curpoint ) self . alltextlayers . append ( curtext ) self . curlayers . append ( point [ 1 ] ) self . curtextlayers . append ( point [ 1 ] ) self . menu_needs_refreshing = True
Load a kml from file and put it on the map