Hide street name, show State (Google Maps)

Very nice plugin!

I would like to hide the name of the street and add the state to the shown location with Google Maps. I have tried dozen of codes but cant get what I need, Any thoughts? Thanks.

Thanks for your message — our team will reply shortly.

In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.

Ok, I just solved it. If you guys want the solution posted for others leave the topic, otherwise you can delete it. Thank you!

Javascript:

document.addEventListener(“DOMContentLoaded”, function () {
function cleanLocation(el) {
    if (!el || el.dataset.cleaned === "true") return;

    let fullText = el.textContent.trim();
    if (!fullText.includes(",")) return;

    let parts = fullText.split(",").map(p => p.trim());

    // Remove street (first part)
    if (parts.length > 1) {
        parts.shift();
    }

    // Remove county
    parts = parts.filter(p => !/county/i.test(p));

    // Remove country
    parts = parts.filter(p => !/united states/i.test(p));

    let cleaned = parts.join(", ");

    // Replace ONLY text (keep icon)
    let icon = el.querySelector("i, svg");

    el.innerHTML = "";

    if (icon) el.appendChild(icon);

    el.appendChild(document.createTextNode(" " + cleaned));

    el.dataset.cleaned = "true";
}

function run() {
    document.querySelectorAll(".hp-listing__location, .hp-user__location").forEach(cleanLocation);
}

// Run after full load
window.addEventListener("load", function () {
    run();
    setTimeout(run, 1000);
    setTimeout(run, 2500);
});
});
2 Likes

Hi,

At the moment, there is no option to customize the address format, but we do plan to add it in the future. For now, the address is saved exactly as it’s returned by the Google Maps API.

There is one option you might consider: “Hide exact address”. It still shows part of the address (such as the street), but hides the full details.

Also, thank you for sharing the temporary solution, it may be very helpful for others.