Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 20th, 2013  |  syntax: None  |  size: 2.74 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <script src="https://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
  2.  
  3. <script>
  4.       var map;
  5.       var infowindow;
  6.  
  7.       function initialize() {
  8.         var pyrmont = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
  9.  
  10.         map = new google.maps.Map(document.getElementById('map1'), {
  11.           mapTypeId: google.maps.MapTypeId.ROADMAP,
  12.           center: pyrmont,
  13.           zoom: 15
  14.         });
  15.  
  16.         var request = {
  17.           location: pyrmont,
  18.           radius: 500,
  19.           types: ['school' , 'mosque']
  20.         };
  21.         infowindow = new google.maps.InfoWindow();
  22.         var service = new google.maps.places.PlacesService(map);
  23.         service.search(request, callback);
  24.       }
  25.  
  26.       function callback(results, status) {
  27.         if (status == google.maps.places.PlacesServiceStatus.OK) {
  28.           for (var i = 0; i < results.length; i++) {
  29.             createMarker(results[i]);
  30.           }
  31.         }
  32.       }
  33.       base_Icon = "<?php echo JURI::base();?>components/com_properties/includes/img/school.png";        
  34.         shadow_Icon = "<?php echo JURI::base();?>components/com_properties/includes/img/house-shadow.png";
  35.  
  36.       function createMarker(place) {
  37.         var placeLoc = place.geometry.location;
  38.         var marker = new google.maps.Marker({
  39.           map: map,
  40.           position: place.geometry.location,
  41.         shadow: shadow_Icon,
  42.         icon: base_Icon
  43.         });
  44.  
  45.         google.maps.event.addListener(marker, 'mouseover', function() {
  46.           infowindow.setContent(place.name);
  47.           infowindow.open(map, this);
  48.         });
  49.       }
  50.  
  51.       google.maps.event.addDomListener(window, 'load', initialize);
  52.     </script>
  53.  
  54. <div id="map1" style=" width:<?php echo $params->get('WidthMap','100%');?>; height:<?php echo $params->get('HeightMap','300px');?>;margin:0px;padding:0px;"></div>
  55.        
  56. base_Icon_school = "<?php echo JURI::base();?>components/com_properties/includes/img/school.png";        
  57.     base_Icon_mosque = "<?php echo JURI::base();?>components/com_properties/includes/img/mosque.png";  
  58.     shadow_Icon = "<?php echo JURI::base();?>components/com_properties/includes/img/house-shadow.png";
  59.  
  60.   function createMarker(place) {
  61.     var placeLoc = place.geometry.location;
  62.     var marker;
  63.     var icon_to_use;
  64.  
  65.     if (place.types.indexOf('school') != -1) {
  66.            icon_to_use =  base_Icon_school;
  67.     } else if (place.types.indexOf('mosque') != -1) {
  68.            icon_to_use =  base_Icon_mosque;
  69.     }
  70.  
  71.     marker = new google.maps.Marker({
  72.       map: map,
  73.       position: place.geometry.location,
  74.     shadow: shadow_Icon,
  75.     icon: icon_to_use  
  76.     });
  77.  
  78.     google.maps.event.addListener(marker, 'mouseover', function() {
  79.       infowindow.setContent(place.name);
  80.       infowindow.open(map, this);
  81.     });
  82.   }