Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple pins to Google Maps by UK post code

Tags:

google-maps

My Google search skills are failing me today. I can add one pin to a Google map using a UK post code. But I can't find how to add multiple pins from a selection of say 100 post codes.

All help apprecaited!

like image 890
tonyyeb Avatar asked Apr 14 '10 15:04

tonyyeb


People also ask

Can you put multiple pins on Google Maps?

A map can have up to 10,000 lines, shapes, or places. Select a layer and click where to put the place. A layer can have 2,000 lines, shapes, or places.

How do I put multiple locations on a Google map?

You can add multiple locations by opening the map which you have created and then clicking on the Add marker button. From there, as already explained, you can add your locations manually or by using the search box. Now that you have added the locations, you need to embed your map.


1 Answers

You may want to check out the following example. I believe it should be self explanatory for you to follow:

<!DOCTYPE html>
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps API Geocoding Demo</title> 
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false"
            type="text/javascript"></script> 
  </head> 
  <body onunload="GUnload()"> 
    <div id="map_canvas" style="width: 400px; height: 300px"></div> 

    <script type="text/javascript"> 
       var geocoder = new GClientGeocoder();
       var map = new GMap2(document.getElementById("map_canvas"));
       var i;

       var postcodes = [
          'SL59JH',
          'LU13TQ',
          'SR29TD',
          'DA75BQ',
          'EC1V9B'
        ];

       map.setCenter(new GLatLng(54.00, -3.00), 5);

       for (i = 0; i < postcodes.length; i++) {
          geocoder.getLatLng(postcodes[i] + ', UK', function (point) {         
             if (point) {
                map.addOverlay(new GMarker(point));
             }
          });
       }
    </script> 
  </body> 
</html>

Screenshot:

Google Maps API Geocoding Demo

like image 158
Daniel Vassallo Avatar answered Jan 02 '23 23:01

Daniel Vassallo