Hello Rossko,

Thank you for your reply,

I looked at your link but the guide that I've provided does not
resolve exactly what to do

I thought, however, to calculate how many miles each store compared to
it has been selected through this function that I found:


InitDistances function () {
  StartLocation var = new GLatLng (startLat, startLon);
  endLocation var = new GLatLng (endLat, endLon);
  var dist = StartLocation. DistanceFrom (endLocation);
  / / Convert distance to Kilometres
  return (dist / 1000). toFixed (2);
}

where the latitude and longitude them income through my geocoder with
the string "results [0]. geometry.location" and if the distance is not
more than 30 km I can see that address and otherwise jump to the next
address   and so on.

I only know where to put this function in my code.

This is the function that I use to display my map (function works
good).




 // Set My Arrays

//This is the list of addreses
    locations = new Array();

//this contain the list of description for each address
    InfoString = new Array();


    var map;
    var geocoder;

    //images
    var image;
//set the zoomlevel
    var zoom;

    var visual;




    var index = 0;

    var geocoderFunction = function() {

        if (index == 0) {

            //var test = findObjWithClientId("hd_ind");
            //elenco = test.value;
            //locations = elenco.split("|");

            image = "0"


            locations[0] = "Piazza Maggiore, 40128, Bologna, Emilia
Romagna"
            locations[1] = "Vicolo San Giobbe, 40128, Bologna, Emilia
Romagna"
            locations[2] = "Via Monte Grappa, 40128, Bologna, Emilia
Romagna"
            locations[3] = "Via Barberia, 40128, Bologna, Emilia
Romagna"
            locations[4] = "Via Riva di reno, 40128, Bologna, Emilia
Romagna"
            locations[5] = "Via Marsala, 40128, Bologna, Emilia
Romagna"
            locations[6] = "Via Bocca di Lupo, 40128, Bologna, Emilia
Romagna"




            InfoString[0] = "Piazza Maggiore, 40128, Bologna, Emilia
Romagna"
            InfoString[1] = "Vicolo San Giobbe, 40128, Bologna, Emilia
Romagna"
            InfoString[2] = "Via Monte Grappa, 40128, Bologna, Emilia
Romagna"
            InfoString[3] = "Via Barberia, 40128, Bologna, Emilia
Romagna"
            InfoString[4] = "Via Riva di reno, 40128, Bologna, Emilia
Romagna"
            InfoString[5] = "Via Marsala, 40128, Bologna, Emilia
Romagna"
            InfoString[6] = "Via Bocca di Lupo, 40128, Bologna, Emilia
Romagna"




            //var test = findObjWithClientId("hd_desc");
            //desc = test.value;
            //InfoString = desc.split("||");

            //var testimage = findObjWithClientId("hd_image");
            //image = testimage.value;

            //var TestzoomMap = findObjWithClientId("hd_zoom");
            //zoomMap = parseInt(TestzoomMap.value);

//set the map type
            var mapOpt = {
                mapTypeId: google.maps.MapTypeId.ROADMAP
                //center: new google.maps.LatLng(38.00, -100.00),
                //zoom: 6
            };

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

            geocoder = new google.maps.Geocoder();

        }



        geocoder.geocode({ 'address': locations[index] },
function(results, status) {
            //document.write(status + " ; ");
            if (status == google.maps.GeocoderStatus.OK) {
                if (index == 0) {
                    map.setCenter(results[0].geometry.location);
                    map.setZoom(zoom);


                    // Cyrcle On the map
                    var circle = new google.maps.Circle({
                        center: results[0].geometry.location,
                        map: map,
                        radius: 1000 // 1 km
                    });

                }

                //Creo la mia infowindows
                var infowindow = new google.maps.InfoWindow({
                    content: InfoString[index]
                });

                if (image == "0") {
                    var marker = new google.maps.Marker
                           ({ map: map,
                               position: results[0].geometry.location,
                               animation: google.maps.Animation.DROP,
                               title: "Store"
                               //icon: "images/fumetto.png"
                           });
                };
                if (image == "1") {
                    var marker = new google.maps.Marker
                           ({ map: map,
                               position: results[0].geometry.location,
                               animation: google.maps.Animation.DROP,
                               title: "Showroom"
                               //icon: "../../images/fumettoHQ.png"
                           });
                };

                //A Ogni ciclo assegno alla al mio Marker una
Infowindows che si aprirà al click del mouse
                google.maps.event.addListener(marker, 'click',
function() {
                    infowindow.open(map, marker);
                });


                alert(results[0].geometry.location);
            }



            else {

                alert(status + " at position" + locations[index]);


            }

            // Call the geocoder with a 1000ms delay
            index++;
            if (locations.length > index) {
                setTimeout(geocoderFunction, 1000);
            }
        });
        if (index == locations.length) {

            index = 0;


        }
    }


Can you give me some suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to