Any agreement to maintain parking meters on a public way shall not affect the right of a city, acting by virtue of its police power, to control, regulate, or prohibit the parking of vehicles on any public way, or portion thereof, to the extent necessary to protect the public safety.