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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:38:45+00:00 2026-05-30T00:38:45+00:00

Currently I have JavaScript that displays markers on a Google map using the Google

  • 0

Currently I have JavaScript that displays markers on a Google map using the Google places but I just refactored my code in order to reduce duplicate functions and put these into arrays. After refactoring the code the markers are no longer being displayed.

Here is my code.

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?    sensor=true&libraries=places"></script>
 <script type="text/javascript">

var map = [], infoWindow = [];

function initialize(){
    initMap(0, 51.5069999695, -0.142489999533);
    initMap(1, 40.79445,-74.01558);
    initMap(2 , 48.858001709, 2.29460000992);
}

function initMap(ndx, lat, lng){
    var feed = new google.maps.LatLng(lat, lng);

    map[ndx] = new google.maps.Map(document.getElementById('map'+ndx), {
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: feed,
        zoom: 11
    });

    var request = {
        location: feed,
        radius: 5000
    };

    infoWindow[ndx] = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService(map);
    service.search(request, callback);
}
function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
        for (var i = 0; i < results.length; i++) {
            createMarker(0, results[i]);
            createMarker(1, results[i]);
            createMarker(2, results[i]);
        }
    }
}

function createMarker(ndx, place) {  =
    var marker = new google.maps.Marker({
        animation: google.maps.Animation.DROP,
        map: map[ndx],
        position: place.geometry.location
    });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow[ndx].setContent(place.name);
        infowindow[ndx].open(map[ndx], this);
    });        
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>

<div id="map0" style="position:absolute; width: 290px; height: 300px;"></div>

<div id="map1" style="position:absolute; left:490px; width: 290px; height: 300px;"></div>

<div id="map2" style="position:absolute; left:790px; width: 290px; height: 300px;"></div>

I have tried to find the problem but I’m not getting anywhere.
Any suggestions?

  • 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-30T00:38:46+00:00Added an answer on May 30, 2026 at 12:38 am

    shouldn’t

    var service = new google.maps.places.PlacesService(map);
    

    be

    var service = new google.maps.places.PlacesService(map[ndx]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Google map that is showing a number of markers. When the
I currently have a Javascript function that uses a string to reference an object
I have a little bit of Javascript that almost works correctly. Here's the code:
I have a javascript-based client that is currently polling a .NET web service for
I currently have an application that calls creates and displays charts from various objects'
I have an autocomplete widget that displays text w/ images. Currently my results look
I'm trying to get multiple markers on a Google map using API V3. The
I currently have a report with pagination, that displays 20 records at a time.
I've got an html page that currently displays the videos of a playlist but
Hi I currently have span that displays over an image on hover, however I

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.