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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:20:57+00:00 2026-06-03T23:20:57+00:00

I am working on an ASP.NET project and I am using Google Maps in

  • 0

I am working on an ASP.NET project and I am using Google Maps in it. I load the map on page load. Then by clicking a button I want to add some markers. I am using the following code.

function LoadSecurity(locationList, message) {
    if (document.getElementById("map_canvas") != null && 
        document.getElementById("map_canvas") != "null") {

        map = new google.maps.Map(document.getElementById("map_canvas"), 
            myOptions);

        for (var i = 0; i < locationList.length; i++) {
            if ((i == 0) || (i == locationList.length - 1)) {
                var args = locationList[i].split(",");
                var location = new google.maps.LatLng(args[0], args[1])
                var marker = new google.maps.Marker({
                    position: location,
                    map: map
                });
                marker.setTitle(message[i]);
            }
        }
    }
}

And I call the function on a button with the following code.

<asp:Button ID="Button1" runat="server" 
    OnClientClick="javascript: LoadSecurity('57.700034,11.930706','test')"
    Text="Button" />

But is not working. Any help please?

  • 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-03T23:20:58+00:00Added an answer on June 3, 2026 at 11:20 pm

    You ask for the element at place ‘i’ here, but your locationList is just a string at that point?

    locationList[i].split(","); 
    

    Try changing it to

    locationList.split(","); 
    

    But there are still some other rather strange things in your code..
    Your for loop goes from 0 to the length of locationList, but at that point locationList is a string and not an array. So your for loop goes from 0 to 19…

    If you are trying to just get 2 coordinates from that string you pass, have a look at the following jsfiddle: http://jsfiddle.net/f3Lmh/

    If you are trying to pass multiple coordinates in that string, you’ll have to slightly change the way you pass them, so it’s easy to see wich coordinates belong to who.
    I prepared another small jsfiddle: http://jsfiddle.net/f3Lmh/4/

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

Sidebar

Related Questions

I'm currently working on an ASP.NET project where I'm using the Google Maps API
We are working on a ASP.NET project and we are using the resx files
I am currently working on a C# project using ASP.NET. And I'd like to
I'm working on an ASP.NET project for a school. In one area I want
I am working on a CMS project using ASP.Net 3.5/Visual studio 2008.This is the
I am working on a c# project using ASP .net. I have a list
I am working on asp.net MVC 3 project. I am using EF 4.1 code
I'm working on an ASP.NET project using MVP architecture. We would like to use
I'm working on an ASP.NET MVC project using jQuery. I'm referencing the jQuery VSDoc
I'm working on a web application project using ASP.NET MVC3 and database in SQL

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.