Any city or city and county may own and operate street railways within or without its corporate limits and may occupy the same street or tracks occupied or used by any street railway within its limits for any number of blocks, upon payment to the owner thereof of an equal portion of the estimated cost of construction, at the time of such occupation, of such tracks or appurtenances as the city or city and county elects to use jointly with the street railway.