Skip to content Skip to sidebar Skip to footer

Mark Multiple Locations In Google Map

I am using Google map api v3 to plot markers of location array. My script is function OnSuccess(response) { var markers = response.d.split('^^'); var latln

Solution 1:

In page.aspx. insert tag <div id="map-canvas" ></div>

view source page.aspx and insert script into it>

var lis_marker = new Array();
for (i = 0; i < markers.length; i++) {
            var data = markers[i];

            geocoder.geocode({ 'address': data }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);


                    lis_marker[i] = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                        title: data  
                    });


                } else {
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });
        }

there are difference with your code:

1: var lis_marker = new Array();

2: lis_marker[i] = new google.maps.Marker({...});


Post a Comment for "Mark Multiple Locations In Google Map"