Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAUtVdh2rS-N7XCLuIrPvH5NhSnb3S31Tw"
- type="text/javascript">
- </script>
- <script type="text/javascript">
- var map;
- function init(){
- map = new google.maps.Map(document.getElementById('maps'), {
- zoom: 10,
- center: new google.maps.LatLng(-7.320795, 112.731386),
- mapTypeId: google.maps.MapTypeId.ROADMAP
- });
- <?php foreach($get_data->result() as $row) {
- $nilai = $row->nilai;
- if($nilai >= 0 && $nilai <=50) {?>
- var icons = {
- info: {
- icon: '<?php echo base_url("assets/marker_merah.png");?>'
- }
- };
- <?php }elseif($nilai >= 51 && $nilai <=69){ ?>
- var icons = {
- info: {
- icon: '<?php echo base_url("assets/marker_hijau.png");?>'
- }
- };
- <?php }elseif($nilai >= 70) { ?>
- var icons = {
- info: {
- icon: '<?php echo base_url("assets/marker_biru.png");?>'
- }
- };
- <?php }
- } ?>
- var features = [
- <?php foreach($get_data->result() as $row){ ?>
- {
- position: new google.maps.LatLng(<?php echo $row->lat;?>,<?php echo $row->long;?>),
- type: 'info',
- title : '<?php echo $row->nama;?>'
- },
- <?php } ?>
- ];
- // Create markers.
- features.forEach(function(feature) {
- var marker = new google.maps.Marker({
- position: feature.position,
- icon: icons[feature.type].icon,
- title: feature.title,
- map: map
- });
- });
- }
- google.maps.event.addDomListener(window, 'load', init);
- </script>
Add Comment
Please, Sign In to add comment