Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6789691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:38:05+00:00 2026-05-26T17:38:05+00:00

The following is my reverse geocoding javascript: google.maps.event.addListener(marker, ‘drag’, function() { geocoder.geocode({‘latLng’: marker.getPosition()}, function(results,

  • 0

The following is my reverse geocoding javascript:

google.maps.event.addListener(marker, 'drag', function() {
        geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            if (results[0]) {
              $.each(results[0].address_components, function(i,v) {
                if (v.types[0] == 'postal_code') {
                  $('#zip').val(v.long_name);
                }
                if (v.types[0] == 'locality') {
                  $('#city').val(v.long_name);
                }
                if (v.types[0] == 'administrative_area_level_1' || v.types[0] == 'administrative_area_level_2') {
                  $('#state').val(v.long_name);
                }
                if (v.types[0] == 'country') {
                  $('#country').val(v.long_name);
                }
              });
              $('#address').val(results[0].formatted_address);
              $('#lat').val(marker.getPosition().lat());
              $('#lng').val(marker.getPosition().lng());
            } else {
              alert("No results found. Please revise your address or adjust your marker.");
          }
        });
      });

First when the result for City is AAA, then the input[type=text]#city will be AAA. When I reverse geocode again, the return address does not have city in it. Instead of clearing the previous values, the AAA is left in the input text field.

Is there any way to clear the field when no results returned?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:38:05+00:00Added an answer on May 26, 2026 at 5:38 pm

    just clear it when the function is run like so

    //put this at the top of your function
    $('#address').val("");
    

    Do the same for any other fields you need to clear

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following method to reverse geocode a google maps latlng: [GClientGeocoder.getLocations(address:String,
I am using google maps Api V3 and using reverse geocoding to find the
in the following simple reverse function I'm always off by one, meaning the first
I am following an example of a book in writing a function to reverse
We are using reverse-geocoding in a rails webservice, and have run into quota problems
I'm using ruby and googles reverse geocode yql table to ideally automate some search
Im trying to reverse the order of the following linked list, I've done so,
Engaging in reverse engineering I found today the following snipet: <script id=idea type=text/x-jqote-template> <![CDATA[
Is the following even possible? I want to reverse the input given to antlr
I have several views with @login_required decorator. And I'm going to use django.core.urlresolvers.reverse() function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.