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

  • SEARCH
  • Home
  • 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 7748295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:44:50+00:00 2026-06-01T10:44:50+00:00

im creating a route shower with geocoding and reverse geocoding. Works quite well, but

  • 0

im creating a route shower with geocoding and reverse geocoding.
Works quite well, but when I want to drag markers I’d like to update proper input with updated address. Problem is I can’t destinguish start and end point. With the following code if i have only 1 point it updates the start address properly, but after adding another point, both of them start to update the same input. (don’t know if i had a good idea to distinguish them by property – i add those points to array, and depending on its lenght it should add property destination with ‘start’ or ‘stop’. Seems like after adding second marker it updates the destination value of previous one).

function placeMarker(location) {
if(list.length < 2) {
    marker = new google.maps.Marker({
        position: location,
        map: map,
        draggable:true,
        animation: google.maps.Animation.DROP,
        destination: 'start'
    });
    map.setCenter(location);
    list.push(marker);
    if (list.length == 2) {
        list[1].destination = 'stop';
    };
    geocoder.geocode({'latLng': location}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (results[0]) {
                if(list.length == 1) {
                    $('#start').val(results[0].formatted_address);
                } else {
                    $('#end').val(results[0].formatted_address);
                }
            }
        }
    });
}
if (list.length == 2) {
    drawRoute(list[0].getPosition(), list[1].getPosition());
};
google.maps.event.addListener(marker, 'drag', function(event) {
    console.log(marker.destination);
    geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (marker.destination == 'start') {
                $("#start").val(results[0].formatted_address);
            } else {
                $("#end").val(results[0].formatted_address);
            }
        }
    });
});
};

Thank You for help!

  • 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-06-01T10:44:52+00:00Added an answer on June 1, 2026 at 10:44 am

    You are attaching eventListener to only one marker, instead of

    google.maps.event.addListener(marker, 'drag', function(event){...})
    

    you should do something like

    google.maps.event.addListener(list[0], 'drag', function(event){...})
    google.maps.event.addListener(list[1], 'drag', function(event){...})
    

    and those listeners should be attached every time marker is created.

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

Sidebar

Related Questions

I am creating a blog engine, and I need a custom route, like this:
Im creating a ServiceMix module that consists of a Camel route. In my beans.xml,
I am working on creating a new controller/route to only allow an HTTP GET
After creating a Web Application project in VS2010, adding a routing route and run
During the processing of an Exchange received from JMS I'm creating dynamically a route
Question: I am creating a wiki software, basically a clone of wikipedia/mediawiki, but in
I'm creating a windows 8 application (but I suspect that any one using Xaml
Hi I am creating a program to find a route between two station in
I am creating a blog application on Rails 3, and I want to override
I'm currently creating an admin tool for a new project which I would like

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.