"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, December 26, 2012

Find the center of map depending on markers position in google maps

find the center of map depending on markers position in Google maps







function init() {
            // alert('hai')
            var mapCenter = new google.maps.LatLng(0, 0);
            var map = new google.maps.Map(document.getElementById('map'), {
                'zoom': 5,
                'center': mapCenter,
                'mapTypeId': google.maps.MapTypeId.ROADMAP
            });
  var image = new google.maps.MarkerImage('../../Scripts/Images/navsubg.png',
                      new google.maps.Size(20, 32),
                      new google.maps.Point(0, 0),
                      new google.maps.Point(0, 32));
            var shadow = new google.maps.MarkerImage('../../Scripts/Images/beachflag_shadow.png',
                      new google.maps.Size(37, 32),
                      new google.maps.Point(0, 0),
                      new google.maps.Point(0, 32));
            var shape = {
                coord: [1, 1, 1, 20, 18, 20, 18, 1],
                type: 'poly'
            };
            var bounds = new google.maps.LatLngBounds();
Start Loop for Add Marker Starst here
var myLatLng = new google.maps.LatLng(Latitude, Longitude);
                    var marker = new google.maps.Marker({
                        position: myLatLng,
                        map: map,
                        shadow: shadow,
                        icon: image,
                        shape: shape,
                        title: info.Zip,
                        animation: google.maps.Animation.DROP
                    });
                    bounds.extend(myLatLng);
Loop for Add Marker Ends Here




If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

No comments: