Can I Validate an Address While Using addMarker?

The "Fast Lane" Answer

No. How was that for a fast answer?

addMarker is a function of Google's mapping service, and—little—known fact—Google Maps' mapping service doesn't actually validate addresses. So, if you're looking for a little validation, you'll need to try a different approach in order to get it. In short, if you want an address validated, you'll need to run it through an address validator. You know...like us.

The "Scenic Route" Answer

As the saying goes, "Jack of all trades, master of none." Google has decided to do a lot of things really well. That expertise comes at the expense of some things that they don't do at all. So while they offer a stellar mapping service, they don't really play well with the addresses themselves (they don't validate). They do work pretty well with geocodes, though, so there is a bit of a workaround for this problem. We'll get to that later. First, though, it's important to know the parts. Let's start with the map and addMarker.

Google Maps is exactly what it says on the can: a mapping service. addMarker is a fun little method that allows you to, as the name implies, add a marker for an address on the map. But it doesn't do anything other than drop a pin where the address should be.

What is address validation? Address validation is the process of comparing a given address to an authoritative database to see if it's registered in the system. A registered address will come back as "valid," which meansit's real and deliverable. Otherwise, an address comes back as "invalid," meaning the address is either not real, not being used, or not in the system.

Validation is a useful tool for making sure your mail will arrive at its destination. Most address validation services, however, don't map the address for you (like Google does), though many (Smarty (formerly SmartyStreets) included) return the address' geocode in the data that's returned.

Which brings us to that workaround we mentioned.

Geocodes (the GPS coordinates, meaning latitude and longitude) give us an accurate definition of a particular location in real terms. It's these coordinates that Google is trying to approximate on a map when you give them an address.

In the fall of 2022, Google launched a new address validation product. The new product features strict terms of service and doesn't allow address data/geocode storage beyond 30 days for most use cases. The permitted uses of address and geocode data is also limited. For most people that need geocodes for Markers, a non-Google address/geocode provides fewer obstacles. Learn more about the abilities and limitations of Google Address Validation here.

So if you validate an address first, using Smarty then give the provided geocodes to Google, you can get them to mark the location of a verified real address on the map. It's what Google is trying to represent when they drop the pin on their map. So the solution to the "address validation via addMarker" problem is not getting Google's map to prove to you a location exists. Rather, it's proving that the address exists first by validating it, and then giving it to Google to ask where it is.

Here's the step-by-step how-to, in a tidy, numbered list:

  1. Choose an address validation service provider (preferably one with stunning good looks and an impeccable sense of humor, like us) that offers supplemental address geocoding data.
  2. Validate your addresses to prove their existence and acquire the relevant geocodes.
  3. Plug the geocodes into Google Maps (or other preferred service—you rebel, you).
  4. Enjoy the visual representation of your desired location.

Just for kicks and giggles, let's step through this with an example address. Let's take something like:

20 Ingram St, Queens NY

First we validate it. We'll go ahead and use Smarty's address validator to verify an address since it's close at hand. After hitting the big blue button, our system gave back this:

Once the address is validated, the coordinates will be listed.

That gives us the good news we were looking for: the address is valid. The next step requires the geocodes tied to the address, which our system provided as part of the validation feedback. Those coordinates happen to be:

40.71276, -73.84269

Now we take them and plug them into Google (via whatever interface you wish to use; for simplicity we just plugged it into the Google Maps search bar). The result is this:

Copy the coordinates and plug them into Google.

And we're done! We successfully mapped the exact location of a real address via Google's services (with Smarty on the assist).

In the end, it's not a matter of "Does Google know everything?"—it's a matter of "Will Google tell me everything I want to know and allow me to use that information the way I need?" Unfortunately, Google limitations (and it's addMarker function) make it challenging. It's like drinking milk that's past its date: you think it's good, but you really don't want to be wrong. Adding address validation, however, will give you exactly what you're looking for. It's perhaps one step longer than you were hoping, but it pays to be sure. Like with the milk.

Seriously, pour it down the drain already.

So remember kids: stay in school, and always validate your addresses before using addMarker.

Ready to get started?