Down a dirt road in northwest Oklahoma, only a few hundred yards from where the city of Enid draws its drinking water, a company injects the toxic byproduct of oil production deep underground.
That close proximity violates a state rule meant to protect public groundwater supplies from oil field wastewater, which can be saltier than the sea and laden with toxic metals. Injection operations are banned within a half-mile of public water wells unless regulators hold a hearing to ensure that such activity will not pollute the water.
But in 2018, without a hearing, state regulators approved this injection well, an apparatus that applies pressure to dispose of wastewater down a steel tube. And in the years since, the well, named the Flying Monkey, has repeatedly failed structural integrity tests, signaling a potential leak.
The Frontier and ProPublica mapped every injection well in the state to determine how close they are to public water wells. We identified at least 114 injection wells in communities across Oklahoma — including the Flying Monkey and two others in Enid — that are located within a half-mile of a public water supply well. More than 300,000 Oklahomans live in communities that rely on these water wells, according to our analysis.
`;
if (activePopup) activePopup.remove();
activePopup = new mapboxgl.Popup({
closeButton: true,
offset: 8,
})
.setLngLat(coords)
.setHTML(html)
.addTo(map);
}
return;
}
const pwsFeatures = map.queryRenderedFeatures(e.point, {
layers: [“pws-fill”, “pws-outline”],
});
if (pwsFeatures.length > 0) {
const props = pwsFeatures[0].properties;
const entry = pwsList.find(
(p) => p.pwsid === props.pws_pwsid,
);
if (entry) {
document.getElementById(“search-input”).value =
entry.name;
selectPWS(entry);
}
}
});
// Cursor changes
[
“uic-clusters”,
“uic-unclustered”,
“pws-fill”,
“pws-outline”,
].forEach((layerId) => {
map.on(“mouseenter”, layerId, () => {
map.getCanvas().style.cursor = “pointer”;
});
map.on(“mouseleave”, layerId, () => {
map.getCanvas().style.cursor = “”;
});
});
map.on(“dragstart”, hideAnnotation);
map.on(“wheel”, hideAnnotation);
map.on(“zoomstart”, hideAnnotation);
if (!initialLoadDone) {
initialLoadDone = true;
map.once(“idle”, () => {
positionAnnotation();
document.getElementById(“swoopy-svg”).style.display =
“block”;
annotationVisible = true;
});
} else if (activePwsEntry) {
// Style reload: restore the active PWS filter without zooming
filterWellsTo(activePwsEntry.pwsid);
}
}
function zoomToPWSBounds(feature, pwsid, opts = {}) {
const associated = wellPairs.features.filter(
(f) => f.geometry && f.properties.pws_pwsid === pwsid,
);
const combined = turf.featureCollection([feature, …associated]);
const bbox = turf.bbox(combined);
map.fitBounds(
[
[bbox[0], bbox[1]],
[bbox[2], bbox[3]],
],
{ padding: 80, maxZoom: 13, …opts },
);
}
function filterWellsTo(pwsid) {
const f = [“==”, [“get”, “pws_pwsid”], pwsid];
map.setFilter(“wells-pws-dim”, [
“all”,
[“==”, [“get”, “well_type”], “pws”],
[“!”, [“>”, [“coalesce”, [“get”, “distance_meters”], -1], 0]],
f,
]);
map.setFilter(“wells-pws”, [
“all”,
[“==”, [“get”, “well_type”], “pws”],
[“>”, [“coalesce”, [“get”, “distance_meters”], -1], 0],
f,
]);
map.setLayoutProperty(“wells-pws-dim”, “visibility”, “visible”);
map.setLayoutProperty(“wells-pws”, “visibility”, “visible”);
map.setFilter(“pws-fill-active”, [
“==”,
[“get”, “pws_pwsid”],
pwsid,
]);
map.getSource(“uic-clusters-source”).setData(
getUICFeatureCollection(pwsid),
);
}
function hideWells() {
map.setLayoutProperty(“wells-pws-dim”, “visibility”, “none”);
map.setLayoutProperty(“wells-pws”, “visibility”, “none”);
map.setFilter(“pws-fill-active”, [“==”, [“get”, “pws_pwsid”], “”]);
map.getSource(“uic-clusters-source”).setData({
type: “FeatureCollection”,
features: [],
});
}
function getPWSWellCounts(pwsid) {
const pws = wellPairs.features.filter(
(f) =>
f.properties.well_type === “pws” &&
f.properties.pws_pwsid === pwsid,
);
const proximal = pws.filter(
(f) =>
f.properties.distance_meters != null &&
f.properties.distance_meters > 0,
).length;
return { proximal, total: pws.length };
}
function showInfoFound(name, uicCount, proximalCount, totalCount) {
const nonproximalCount = totalCount – proximalCount;
document
.getElementById(“info-not-found”)
.classList.remove(“visible”);
const nonProxPart =
nonproximalCount > 0
? tmpl(
` This district also has {{nonproximalCount}}
other drinking water {{pluralize(nonproximalCount, “well”)}}.`,
{ nonproximalCount, pluralize },
)
: “”;
const sentence = tmpl(
`
In the {{name}} water district,
{{uicCount}}
oil field wastewater disposal {{pluralize(uicCount, “well”)}} {{pluralize(uicCount, “is”, “are”)}} within a half-mile of
{{proximalCount}}
drinking water {{pluralize(proximalCount, “well”)}}.{{nonProxPart}}
`.trim(),
{ name, uicCount, proximalCount, nonProxPart, pluralize },
);
document.getElementById(“info-result-sentence”).innerHTML =
sentence;
document.getElementById(“info-found”).classList.add(“visible”);
document.getElementById(“result-area”).classList.add(“visible”);
}
function showInfoNotFound() {
document.getElementById(“info-found”).classList.remove(“visible”);
document.getElementById(“info-not-found”).classList.add(“visible”);
document.getElementById(“result-area”).classList.add(“visible”);
}
function hideResult() {
document.getElementById(“result-area”).classList.remove(“visible”);
document.getElementById(“info-found”).classList.remove(“visible”);
document
.getElementById(“info-not-found”)
.classList.remove(“visible”);
}
function selectPWS(entry) {
hideAnnotation();
activePwsEntry = entry;
zoomToPWSBounds(entry.feature, entry.pwsid);
const { proximal, total } = getPWSWellCounts(entry.pwsid);
showInfoFound(entry.name, entry.uic_count, proximal, total);
filterWellsTo(entry.pwsid);
}
function selectAddress(coords) {
hideAnnotation();
const point = turf.point(coords);
const matched = pwsPolygons.features.find(
(f) => f.geometry && turf.booleanPointInPolygon(point, f),
);
if (matched) {
activePwsEntry =
pwsList.find(
(p) => p.pwsid === matched.properties.pws_pwsid,
) || null;
zoomToPWSBounds(matched, matched.properties.pws_pwsid);
const { proximal, total } = getPWSWellCounts(
matched.properties.pws_pwsid,
);
showInfoFound(
matched.properties.pws_system,
matched.properties.uic_count,
proximal,
total,
);
filterWellsTo(matched.properties.pws_pwsid);
} else {
activePwsEntry = null;
map.flyTo({ center: coords, zoom: 11 });
showInfoNotFound();
hideWells();
}
}
async function runExampleSearch(text, mode) {
const input = document.getElementById(“search-input”);
input.value = text;
hideResult();
if (mode === “pws”) {
const entry = pwsList.find((p) =>
p.name.toLowerCase().includes(text.toLowerCase()),
);
if (entry) selectPWS(entry);
} else {
try {
const url =
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(text)}.json` +
`?access_token=${TOKEN}&bbox=-103.0,33.6,-94.4,37.0&country=us&types=address,postcode,place&limit=1`;
const res = await fetch(url);
const data = await res.json();
if (data.features && data.features.length > 0) {
selectAddress(data.features[0].geometry.coordinates);
}
} catch (_) {}
}
}
function createUICSquareImage(name, size, borderColor) {
const canvas = document.createElement(“canvas”);
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext(“2d”);
ctx.fillStyle = COLOR_UIC;
ctx.fillRect(0, 0, size, size);
ctx.strokeStyle = borderColor;
ctx.lineWidth = 1;
ctx.strokeRect(0.5, 0.5, size – 1, size – 1);
const imgData = ctx.getImageData(0, 0, size, size);
if (map.hasImage(name)) map.removeImage(name);
map.addImage(name, imgData);
}
function getUICFeatureCollection(pwsid) {
return {
type: “FeatureCollection”,
features: wellPairs.features.filter(
(f) =>
f.properties.well_type === “uic” &&
f.geometry &&
f.properties.pws_pwsid === pwsid,
),
};
}
function initSearch() {
const input = document.getElementById(“search-input”);
const suggestionsEl = document.getElementById(“suggestions”);
let debounceTimer;
let activeIndex = -1;
let suggestionActions = [];
function setActiveIndex(idx) {
const items =
suggestionsEl.querySelectorAll(“.suggestion-item”);
if (activeIndex >= 0 && items[activeIndex]) {
items[activeIndex].classList.remove(“active”);
}
activeIndex = idx;
if (idx >= 0 && items[idx]) {
items[idx].classList.add(“active”);
items[idx].scrollIntoView({ block: “nearest” });
}
}
input.addEventListener(“input”, () => {
hideAnnotation();
clearTimeout(debounceTimer);
debounceTimer = setTimeout(async () => {
const q = input.value.trim();
if (q.length < 2) {
hideSuggestions();
return;
}
const pwsMatches = pwsList
.filter((p) =>
p.name.toLowerCase().includes(q.toLowerCase()),
)
.slice(0, 5);
let addressMatches = [];
try {
const url =
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(q)}.json` +
`?access_token=${TOKEN}&bbox=-103.0,33.6,-94.4,37.0&country=us&types=address,postcode,place&limit=5`;
const res = await fetch(url);
const data = await res.json();
addressMatches = data.features || [];
} catch (_) {}
renderSuggestions(pwsMatches, addressMatches);
}, 250);
});
input.addEventListener(“keydown”, (e) => {
if (e.key === “Escape”) {
hideSuggestions();
input.blur();
} else if (e.key === “ArrowDown”) {
if (!suggestionsEl.classList.contains(“open”)) return;
e.preventDefault();
setActiveIndex(
Math.min(activeIndex + 1, suggestionActions.length – 1),
);
} else if (e.key === “ArrowUp”) {
if (!suggestionsEl.classList.contains(“open”)) return;
e.preventDefault();
setActiveIndex(activeIndex <= 0 ? -1 : activeIndex – 1);
} else if (e.key === “Enter”) {
if (activeIndex >= 0 && suggestionActions[activeIndex]) {
suggestionActions[activeIndex]();
}
}
});
document.addEventListener(“click”, (e) => {
if (!e.target.closest(“.search-wrap”)) hideSuggestions();
});
function renderSuggestions(pwsMatches, addressMatches) {
suggestionsEl.innerHTML = “”;
activeIndex = -1;
suggestionActions = [];
if (!pwsMatches.length && !addressMatches.length) {
hideSuggestions();
return;
}
if (pwsMatches.length) {
const label = document.createElement(“div”);
label.className = “suggestion-group-label”;
label.textContent = “Water Systems”;
suggestionsEl.appendChild(label);
pwsMatches.forEach((entry) => {
const item = document.createElement(“div”);
item.className = “suggestion-item”;
item.textContent = entry.name;
const action = () => {
input.value = entry.name;
hideSuggestions();
hideResult();
selectPWS(entry);
};
suggestionActions.push(action);
item.addEventListener(“mousedown”, (e) => {
e.preventDefault();
action();
});
suggestionsEl.appendChild(item);
});
}
if (addressMatches.length) {
const label = document.createElement(“div”);
label.className = “suggestion-group-label”;
label.textContent = “Addresses & Places”;
suggestionsEl.appendChild(label);
addressMatches.forEach((feature) => {
const item = document.createElement(“div”);
item.className = “suggestion-item”;
item.textContent = feature.place_name;
const action = () => {
input.value = feature.place_name;
hideSuggestions();
hideResult();
selectAddress(feature.geometry.coordinates);
};
suggestionActions.push(action);
item.addEventListener(“mousedown”, (e) => {
e.preventDefault();
action();
});
suggestionsEl.appendChild(item);
});
}
suggestionsEl.classList.add(“open”);
}
function hideSuggestions() {
suggestionsEl.classList.remove(“open”);
suggestionsEl.innerHTML = “”;
activeIndex = -1;
suggestionActions = [];
}
document.querySelectorAll(“.example-link”).forEach((link) => {
link.addEventListener(“click”, (e) => {
e.preventDefault();
hideSuggestions();
runExampleSearch(
link.textContent.trim(),
link.dataset.mode,
);
});
});
}




