After shooting up in public places, people often leave behind dirty needles, posing a health hazard. In response, some groups have called for supervised injection facilities, like those in Canada and Europe, where people can inject themselves under medical supervision. The goal is to keep them from overdosing and to curb infectious diseases. Such facilities are illegal in this country, although the mayor of Ithaca, N.Y., recently suggested opening one.

In Boston, where pedestrians step over drug users who are nodding off on a stretch of Massachusetts Avenue known as Methadone Mile, an organization for the homeless has planned what it calls a safe space, where users could ride out their high under supervision; it would not allow actual injection on site.

New England has been a cradle of the heroin epidemic. Middlesex County, which encompasses Cambridge, a city of 107,000 just west of Boston, has the highest number of overdose deaths from heroin and prescription pain pills in Massachusetts. From 2000 to 2014, Middlesex, which also includes the city of Lowell, a major heroin hotbed, had 1,634 opioid deaths.

No one keeps track of how many deaths occur in public spaces, but law enforcement officials agree the number is high.

“We quite frequently see folks using public areas,” said Robert C. Haas, the Cambridge police commissioner.

It was the fear of someone dying in their bathrooms that led officials at Christ Church Cambridge to close public access to them in 2012. By doing so, the church did not experience the kind of tragic scenes that are occurring around the country, but the decision was difficult.