0

I want to show multiple search results on one embedded map, is this possible?

Example: I want to show all banks in your area that are any of 4 companies: Chase, Wells Fargo, US Bank, Bank of America

This is actually for my Australian website - people visit banks and deposit cash in our accounts at any of 4 banks and I want to just give them a map to find the closest one: https://www.spendbitcoins.com/buy/ "Please visit any of the NAB, Bendigo, Commonwealth Bank or Westpac branches and deposit"

It would be even better if its possible to add a search box so they can type in their city or zip and get a local version.

Jay West
  • 177
  • 10

1 Answers1

-1

Yes this is done by creating an array of them first, as shown below;

  <div id="map" style="width: 500px; height: 400px;"></div>

  <script type="text/javascript">
    var locations = [
      ['Bondi Beach', -33.890542, 151.274856, 4],
      ['Coogee Beach', -33.923036, 151.259052, 5],
      ['Cronulla Beach', -34.028249, 151.157507, 3],
      ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
      ['Maroubra Beach', -33.950198, 151.259302, 1]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>

I lifted this example from a previous question which has more information on the subject

Community
  • 1
  • 1
user1044220
  • 269
  • 1
  • 7
  • 21
  • But this isn't a search.. I would rather not have to input all of the locations up front because there is thousands of them. – Jay West Aug 17 '12 at 22:17
  • This just creates multiple locations from an array, but doesn't show the closests given an specific location – franko_camron Feb 23 '17 at 16:25