Guest User

Untitled

a guest
Jan 17th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. google.maps.event.trigger(map,'resize',{});
  2.  
  3. google.maps.event.addListener(marker, 'click', function() {
  4. //My Google Map Code
  5. });
  6.  
  7. <script>
  8.  
  9. var map;
  10.  
  11. function initMap() {
  12. var map = new google.maps.Map(document.getElementById('map'), {
  13. zoom: 5,
  14. center: {lat: -34.397, lng: 150.644}
  15. });
  16. var geocoder = new google.maps.Geocoder();
  17. geocodeAddress(geocoder, maps);
  18. }
  19.  
  20. function geocodeAddress(geocoder, resultsMap) {
  21. var address = "Ahmedabad India";
  22. geocoder.geocode({'address': address}, function(results, status) {
  23. if (status === 'OK') {
  24. resultsMap.setCenter(results[0].geometry.location);
  25.  
  26. var contentString = '<div id="content">'+
  27. '<div id="siteNotice">'+
  28. '</div>'+
  29. '<h1 id="firstHeading" class="firstHeading">Websters House</h1>'+
  30. '<div id="bodyContent">'+
  31. 'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
  32. 'Aboriginal people of the area. It has many springs, waterholes, '+
  33. 'rock caves and ancient paintings. Uluru is listed as a World '+
  34. 'Heritage Site.</p>'+
  35. '<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
  36. 'https://en.wikipedia.org/w/index.php?title=Uluru</a> '+
  37. '(last visited June 22, 2009).</p>'+
  38. '</div>'+
  39. '</div>';
  40.  
  41. var infowindow = new google.maps.InfoWindow({
  42. content: contentString
  43. });
  44. var marker = new google.maps.Marker({
  45. title: 'Uluru (Ayers Rock)',
  46. map: resultsMap,
  47. position: results[0].geometry.location
  48. });
  49. //Call Listner On Click Markre
  50. marker.addListener('click', function() {
  51. infowindow.open(map, marker);
  52. });
  53.  
  54. } else {
  55. alert('Geocode was not successful for the following reason: ' + status);
  56. }
  57. });
  58. }
  59.  
  60. </script>
  61.  
  62. <script async defer src="https://maps.googleapis.com/maps/api/js?key=XXXXXXMYKEYXXXX&callback=initMap"></script>
Add Comment
Please, Sign In to add comment