def getmap(self, layers=None, styles=None, srs=None, bbox=None,<EOL>format=None, size=None, time=None, transparent=False,<EOL>bgcolor='<STR_LIT>',<EOL>exceptions='<STR_LIT>',<EOL>method='<STR_LIT>',<EOL>timeout=None,<EOL>**kwargs<EOL>):
try:<EOL><INDENT>base_url = next((m.get('<STR_LIT:url>') for m in self.getOperationByName('<STR_LIT>').methods if m.get('<STR_LIT:type>').lower() == method.lower()))<EOL><DEDENT>except StopIteration:<EOL><INDENT>base_url = self.url<EOL><DEDENT>request = {'<STR_LIT:version>': self.version, '<STR_LIT>': '<STR_LIT>'}<EOL>request = self.__build_getmap_request(<EOL>layers=layers,<EOL>styles=styles,<EOL>srs=srs,<EOL>bbox=bbox,<EOL>format=format,<EOL>size=size,<EOL>time=time,<EOL>transparent=transparent,<EOL>bgcolor=bgcolor,<EOL>exceptions=exceptions,<EOL>**kwargs)<EOL>data = urlencode(request)<EOL>self.request = bind_url(base_url) + data<EOL>u = openURL(base_url, data, method, username=self.username, password=self.password, timeout=timeout or self.timeout)<EOL>if u.info().get('<STR_LIT:Content-Type>', '<STR_LIT>').split('<STR_LIT:;>')[<NUM_LIT:0>] in ['<STR_LIT>']:<EOL><INDENT>se_xml = u.read()<EOL>se_tree = etree.fromstring(se_xml)<EOL>err_message = six.text_type(se_tree.find('<STR_LIT>').text).strip()<EOL>raise ServiceException(err_message)<EOL><DEDENT>return u<EOL>
Request and return an image from the WMS as a file-like object.

        Parameters
        ----------
        layers : list
            List of content layer names.
        styles : list
            Optional list of named styles, must be the same length as the
            layers list.
        srs : string
            A spatial reference system identifier.
        bbox : tuple
            (left, bottom, right, top) in srs units.
        format : string
            Output image format such as 'image/jpeg'.
        size : tuple
            (width, height) in pixels.
        transparent : bool
            Optional. Transparent background if True.
        bgcolor : string
            Optional. Image background color.
        method : string
            Optional. HTTP DCP method name: Get or Post.
        **kwargs : extra arguments
            anything else e.g. vendor specific parameters

        Example
        -------
            wms = WebMapService('http://giswebservices.massgis.state.ma.us/geoserver/wms', version='1.1.1')
            img = wms.getmap(layers=['massgis:GISDATA.SHORELINES_ARC'],\
                                 styles=[''],\
                                 srs='EPSG:4326',\
                                 bbox=(-70.8, 42, -70, 42.8),\
                                 size=(300, 300),\
                                 format='image/jpeg',\
                                 transparent=True)
            out = open('example.jpg', 'wb')
            bytes_written = out.write(img.read())
            out.close()