(CNN) — Crowds descended on California beaches, hiking trails and parks over the weekend in open defiance of a state order to avoid close contact with others.

The large number of visitors prompted officials in some cities to order parks, recreation areas and beaches to close. Marin County on Sunday closed all parks — local, state and federal — within its boundaries.

Video and photos on social media showed groups of people standing in close contact of one another at hiking trails and beaches in Los Angeles over the weekend. Health officials urge people to maintain a distance of 6 feet from one another to prevent transmission of the highly contagious coronavirus.

In response to the crowds, Los Angeles Mayor Eric Garcetti announced on Twitter late Sunday that he was closing sports and recreation at all city parks. He also tweeted that parking at city beaches was closed.

“This weekend we saw too many people packing beaches, trails and parks,” the mayor tweeted. He said people should heed the closures and stay home. “That doesn’t mean gather elsewhere. This is serious. Stay home and save lives.”

Garcetti told CNN affiliate KTLA that he was working with officials in neighboring cities and the county to address large crowds at beaches.

Santa Monica closed its beach parking Sunday to deter people from flocking to the shore.

Malibu issued additional guidance urging residents to maintain a safe distance if they were heading outside for a hike or to go to the beach. City-owned parks and trails also were closed to the public.

Long Beach closed many of its recreation facilities. On Sunday night, Mayor Robert Garcia said in a tweet that the city had closed skate parks, dog parks, playgrounds, picnic areas and volleyball, tennis and basketball courts.

Garcia tweeted that the city is also looking to establish additional guidance for the use of its beaches.

He said the onus is on residents to comply with the rules as public safety teams may not be able to enforce the orders.

“More signs are going up at beaches and courts, and we will look to enforce more — but our public safety teams are incredibly busy,” Garcia tweeted. “We need the public to take self responsibility and remember that our doctors, nurses and medical personnel are counting on us.”

In Oregon, it was announced on Sunday that all state parks would be closed until at least May 8.