Guest User

Untitled

a guest
Dec 7th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAUtVdh2rS-N7XCLuIrPvH5NhSnb3S31Tw"
  2. type="text/javascript">
  3. </script>
  4. <script type="text/javascript">
  5. var map;
  6. function init(){
  7. map = new google.maps.Map(document.getElementById('maps'), {
  8. zoom: 10,
  9. center: new google.maps.LatLng(-7.320795, 112.731386),
  10. mapTypeId: google.maps.MapTypeId.ROADMAP
  11. });
  12.  
  13. <?php foreach($get_data->result() as $row) {
  14. $nilai = $row->nilai;
  15. if($nilai >= 0 && $nilai <=50) {?>
  16. var icons = {
  17. info: {
  18. icon: '<?php echo base_url("assets/marker_merah.png");?>'
  19. }
  20. };
  21. <?php }elseif($nilai >= 51 && $nilai <=69){ ?>
  22. var icons = {
  23. info: {
  24. icon: '<?php echo base_url("assets/marker_hijau.png");?>'
  25. }
  26. };
  27. <?php }elseif($nilai >= 70) { ?>
  28. var icons = {
  29. info: {
  30. icon: '<?php echo base_url("assets/marker_biru.png");?>'
  31. }
  32. };
  33. <?php }
  34. } ?>
  35.  
  36. var features = [
  37. <?php foreach($get_data->result() as $row){ ?>
  38. {
  39. position: new google.maps.LatLng(<?php echo $row->lat;?>,<?php echo $row->long;?>),
  40. type: 'info',
  41. title : '<?php echo $row->nama;?>'
  42. },
  43. <?php } ?>
  44. ];
  45.  
  46. // Create markers.
  47. features.forEach(function(feature) {
  48. var marker = new google.maps.Marker({
  49. position: feature.position,
  50. icon: icons[feature.type].icon,
  51. title: feature.title,
  52. map: map
  53. });
  54. });
  55. }
  56. google.maps.event.addDomListener(window, 'load', init);
  57. </script>
Add Comment
Please, Sign In to add comment