Advertisement
Guest User

Nigel Babu

a guest
Sep 3rd, 2010
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function markOnMap(x, y) {
  2.     geocoder = new google.maps.Geocoder();
  3.     latlng = new google.maps.LatLng(x, y);  //center the map to the coordinates of the searched address
  4.     var myOptions = {
  5.         center: latlng,
  6.         zoom: 8,
  7.         mapTypeId: google.maps.MapTypeId.ROADMAP,
  8.         mapTypeControl: false
  9.     }
  10.     map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  11.     var markers = document.getElementById('marker').value;
  12.     var mapPoints = $.parseJSON(markers);
  13.     var marker = new Array();
  14.     i = 0;
  15.     $.each(mapPoints, function() {
  16.         var latlng = new google.maps.LatLng(this.lat, this.lng);
  17.         marker[i] = new google.maps.Marker({
  18.                     map: map,
  19.                     draggable: true,
  20.                     position: latlng,
  21.                     content: '<b>Name : </b>' + this.name, //very important
  22.               });
  23.     google.maps.event.addListener(marker[i], 'click', function() {
  24.         infowind = new google.maps.InfoWindow({
  25.             content: this.content,
  26.             });
  27.         infowind.open(map, this);
  28.         });
  29.     i++;
  30.     });
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement