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 8242303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:07:21+00:00 2026-06-07T21:07:21+00:00

I have this function in javascript, which sets all markers and popup info for

  • 0

I have this function in javascript, which sets all markers and popup info for each marker.

var infowindow = new google.maps.InfoWindow();
for (var i = 0; i < arraylng.length - 1; i++) {
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(arraylng[i], arraylat[i])
    });
    var infowindow = new google.maps.InfoWindow({
        content: " "
    });
    makeInfoWindowEvent(map, infowindow, marker, i);
    markers.push(marker);
}

function makeInfoWindowEvent(map, infowindow, marker, i) {
    google.maps.event.addListener(marker, 'click', function() {
        alert(arraylat[i]); // working nice 
        alert(arraylng[i]); // working nice 
        infowindow.setContent(arraylng[i] + ", " + arraylat[i]);
        infowindow.open(map, marker);
    });
}

                }

My question is: How can I add my method from webservice, which return an address from database? Here is code.

[WebMethod]
public string GetAddressMarker(string lat, string lng) {
    string address = "";
    var plac = GoogleapiBO.getClinicByLatLng(lat, lng);
    address = plac.address + ", " + plac.city;
    address = "'" + address + "'";
    return address;
}

All I need, is to get an address from this method (method needs string lat=arraylat[i] & string lng=arraylng[i]) and set it into infowindow.setContent(*here*);

How can I do this?

  • 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-07T21:07:25+00:00Added an answer on June 7, 2026 at 9:07 pm

    Solution #1

    Webservice:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string GetAddressMarker(string lat, string lng) {
        string address = "";
        var plac = GoogleapiBO.getClinicByLatLng(lat, lng);
        address = plac.address + ", " + plac.city;
        address = "'" + address + "'";
        return address;
    }
    

    Javascript

    function makeRequest(url, message) {
        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        httpRequest.onreadystatechange = getResponse;
        httpRequest.open("POST", url, true);
        httpRequest.setRequestHeader("Content-Type", "application/json");
        httpRequest.send(message);
    }
    
    function getResponse() {
        if (httpRequest.readyState == 4 && httpRequest.status == 200) {
            //convert JSON string into object
            progressInfo(JSON.parse(httpRequest.responseText)) 
        }
    }
    
    function progressInfo(info) {
        //doing something with object info - in your case it should be the string
    }
    

    to call the method:

    makeRequest("http://..../webservice/Service.asmx/GetAdressMarker");
    

    Solution #2

    setting a javascript variable in the c# code:

    <script type="text/javascript">
         var address= '<%= _address%>';
    </script>
    

    code-behind:

    public partial class Entscheidungen : System.Web.UI.Page
    {
        private string _address;
    
        protected void Page_Load(object sender, EventArgs e)
        {
             bt.Command += new CommandEventHandler(bt_Command);
        }
    
        void bt_Command(object sender, CommandEventArgs e)
        {
             _address = Service.GetAddressMarker(string lat, string lng)
        }
    
        ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JavaScript function which is working in all the machines I tried
I have javascript which sets the location of panel and javascript is below function
I have this function which is imported directly in the HTML function include(filename){ var
I have this function in javascript file which works perfectly fine in Firefox /
I have this Javascript function that sends username and password to php file through
So I have this javascript function, it sends an ajax requests to fetch a
I have this function: <script type='text/javascript'> $('#clicktogohome').live('click', function(){ history.pushState({}, '', this.href); popstate(this.href); return false;
I have this function working <script type=text/javascript> $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() -
I have this follow code in my javascript. I call this function when the
I have a JavaScript function that looks like this: function recalculateWhatIfCurrentRate(aEle, aChangedLabel, recordID, yearEndCurrentRate)

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.