public HttpUrl url ( ) { HttpUrl . Builder urlBuilder = HttpUrl . parse ( baseUrl ( ) ) . newBuilder ( ) . addPathSegment ( "styles" ) . addPathSegment ( "v1" ) . addPathSegment ( user ( ) ) . addPathSegment ( styleId ( ) ) . addPathSegment ( "static" ) . addQueryParameter ( "access_token" , accessToken ( ) ) ; List < String > annotations = new ArrayList <> ( ) ; if ( staticMarkerAnnotations ( ) != null ) { List < String > markerStrings = new ArrayList <> ( staticMarkerAnnotations ( ) . size ( ) ) ; for ( StaticMarkerAnnotation marker : staticMarkerAnnotations ( ) ) { markerStrings . add ( marker . url ( ) ) ; } annotations . addAll ( markerStrings ) ; } if ( staticPolylineAnnotations ( ) != null ) { String [ ] polylineStringArray = new String [ staticPolylineAnnotations ( ) . size ( ) ] ; for ( StaticPolylineAnnotation polyline : staticPolylineAnnotations ( ) ) { polylineStringArray [ staticPolylineAnnotations ( ) . indexOf ( polyline ) ] = polyline . url ( ) ; } annotations . addAll ( Arrays . asList ( polylineStringArray ) ) ; } if ( geoJson ( ) != null ) { annotations . add ( String . format ( Locale . US , "geojson(%s)" , geoJson ( ) . toJson ( ) ) ) ; } if ( ! annotations . isEmpty ( ) ) { urlBuilder . addPathSegment ( TextUtils . join ( "," , annotations . toArray ( ) ) ) ; } urlBuilder . addPathSegment ( cameraAuto ( ) ? CAMERA_AUTO : generateLocationPathSegment ( ) ) ; if ( beforeLayer ( ) != null ) { urlBuilder . addQueryParameter ( BEFORE_LAYER , beforeLayer ( ) ) ; } if ( ! attribution ( ) ) { urlBuilder . addQueryParameter ( "attribution" , "false" ) ; } if ( ! logo ( ) ) { urlBuilder . addQueryParameter ( "logo" , "false" ) ; } // Has to be last segment in URL urlBuilder . addPathSegment ( generateSizePathSegment ( ) ) ; return urlBuilder . build ( ) ; }
Returns the formatted URL string meant to be passed to your Http client for retrieval of the actual Mapbox Static Image .