"Error message: The geocoder from Google Maps cannot locate the address

Trying to utilize the geocoder for obtaining coordinates of the address below:

1945 Barton Street, Hamilton, ON, L8H2Y7

A search on Google Maps itself yields the address: . The geocode URL also returns results without any issues. http://maps.googleapis.com/maps/api/geocode/json?address=1945+BARTON+STREET,+HAMILTON,+ON,+L8H2Y7&sensor=false

However, when implementing the API (as shown below), it shows as not found.

Code: (works perfectly for other addresses)

if (geocoder) {
    geocoder.geocode( {'address': fullAddress }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert("Geocoding failed: " + status + "  " + fullAddress);
        }
    });
}

The correct address is actually "1945 Barton Street East, Hamilton, ON L8H2Y7, Canada", but maps and the direct URL can still locate it accurately, only the geocoder seems unable to.

Any thoughts on why this inconsistency might be occurring?

EDIT: I've identified the issue. It was a different address that couldn't be located by the geocoder or on Google Maps, but due to the asynchronous nature of the request, by the time the geocoder realized the address wasn't found, the loop had already changed to another address that could be found. Looks like I have some troubleshooting ahead..

Answer №1

It is unusual because it functions properly on my live demonstration. Please see for yourself:

Live Demo

Is there more code available elsewhere?

Update

I tried using the plus symbol in the service, and even without including Canada, it still worked.

Here are some examples

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React functions properly even without being explicitly imported

I'm feeling unsure about the import React statement. As far as I know, when we want to use JSX, we need to bring in React from the react package. import { Counter } from "./components/Counter"; // import React, { useState } from "react ...

Total sum displayed within the Apex interactive grid

In my APEX application, I am utilizing the Interactive grid feature. In the first row, I entered the value as 1000.00 and in the second row as 500. My goal is to calculate the total value of 1,500.00 and display it in a Hidden item. Currently, I am able t ...

Converting a JavaScript application to iOS and Android using Flutter

My current browser application utilizes javascript,node.js,jquery,HTML5(canvas). Now, I am interested in transferring this application to iOS/Android. I have experience with creating iOS/Android applications using flutter, so I am aware that it is feasib ...

Getting the highest occurrence of a repeated value within an array using JavaScript (with the help of jQuery)

Dealing with multiple arrays is my current task. I am looking to extract the most duplicated value from each array. In the array [3, 7, 7, 7], the value 7 needs to be found. Each array has a size of 4 elements. Currently, I do not need to consider cases w ...

emailProtected pre-publish: Running `python build.py && webpack` command

i am currently using scratch-blocks through the Linux terminal I have encountered a problem which involves running the following command: python build.py && webpack [email protected] prepublish: python build.py && webpack Can anyon ...

Allow foreign characters with regex while excluding special symbols

While browsing, I came across this thread: Is there a regular expression to match non-English characters?. It provides a regex to remove foreign characters using the code snippet str = str.replace(/[^\x00-\x7F]+/g, "");. My goal is slightly diff ...

Guide on inserting the elements <label>, <input>, and <span> into a <li> in a particular sequence

var btn = document.querySelector('.add'); var remove = document.querySelector('.draggable'); function dragStart(e) { this.style.opacity = '0.4'; dragSrcEl = this; ...

Angular 7 - Implementing periodic JSON data retrieval from server and maintaining local storage within Angular application

Seeking guidance on how to handle updating a static json file stored in the assets directory in an Angular 7 project. The goal is to periodically fetch a json from a server, check for updates, and perform post-processing on the data in the static file (ess ...

Error Encountered: AngularJS - 'DashboardController' is Not Registered

I just set up a new angular app and I'm encountering an issue where my controller is not registering. The error message I am receiving states: The controller with the name 'DashboardController' is not registered. My app module and dashbo ...

Storing Personalized Information in Thingsboard; Beyond Telemetry Data

I am currently utilizing the amazing platform of thingsboard. Imagine I have a basic User Form with the following fields: Username First Name Last Name Email Address Phone Number My goal is to store all this information in thingsboard. Can thingsboard h ...

Converting JSON values to different data types

I have a number as the value in this field, but when I retrieve the output is always in string format. Should I typecast it? And if yes, how can I do that? I attempted to use parseInt, but it didn't seem to work. Am I using it incorrectly? Code: ...

Manipulate a deeply nested JSON object in JavaScript by iterating through it and constructing a new data

Struggling to rearrange complex JSON data (data1) into a more organized format (data2). Progress has been slow. data1 is created by scanning a parent directory (recipes) for html files. data2 is the desired output structure using data1, where content wit ...

Exploring the capabilities of utilizing Await/Async functions in Node.js

Here is my custom Axios Request function to make API calls. export function axiosGet (url) { return opsutils.get(url) .then(function (response) { return response.data.data; }) .catch(function (error) { return 'An error occu ...

What is the best way to target an iframe that includes "window.onclick" within its window?

Trying to integrate an HTML canvas game into my website poses a slight issue - the window requires a click on the iframe every time the page loads, which can be quite bothersome. I am looking for a way to automatically focus on the frame without manual int ...

The jQuery hide and show functions lack precision and are too indiscriminate, requiring a more targeted approach

I am designing a unique contact card that captures a user's name and description from an <input> field and appends the input information into a <div> element. This is the flow I am aiming for... User inputs their first and last name alo ...

What could be causing the routing to fail in this script?

Currently working on a small project to dive into AngularJS, and I'm facing some challenges with getting the routing to function properly. Despite following numerous tutorials, my code doesn't seem to be working as expected. If anyone could lend ...

Set up a targeted version of the winston software package for installation

Can I download a specific version of winston through npm by using the command: npm install winston=2.2.0 The reason I am asking is because I am encountering an issue with my existing code written in version 2.2.0 when I download the latest version. The ...

Having issues getting the DataTables responsive feature to work in my sails.js and angularjs project

I've successfully imported the required DataTables css and js files. <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="/bower_components/datatables-plugins/integration/bootstr ...

Attempting to showcase JSON response within an HTML page using JavaScript

Can anyone help me troubleshoot my code for displaying JSON data on a web page? Here's what I have so far: <button type="submit" onclick="javascript:send()">call</button> <div id="div"></div> <script type="text/javascript ...

The NVD3 tooltip is being obscured by other divs

Attempting to make the NVD3 tooltip appear above all other divs has presented a challenge. With three charts lined up horizontally and tooltips that exceed the boundaries of their divs, adjusting the z-index creates a dilemma. Regardless of which side&apos ...