Theme images by Storman. Powered by Blogger.

22 July 2016

How to draw on google maps from point A to point B with specific location?

- No comments
How to point on google maps from point A to point  B with specific location?

Here is the google maps in order to point from start location to our destination on google maps include they draw on road:



HTML


        <div id="floating-panel">
   <b>Mode of Travel: </b>
   <select id="mode">
     <option value="DRIVING">Driving</option>
     <option value="WALKING">Walking</option>
     <option value="BICYCLING">Bicycling</option>
     <option value="TRANSIT">Transit</option>
   </select>
   </div>
   <div id="map"></div>
         </div>

CSS

<style>
 #map {
        width:100%;
        height: 650px;
      }
     #floating-panel {
       position: absolute;
       top: 10px;
       left: 25%;
       z-index: 5;
       background-color: #fff;
       padding: 5px;
       border: 1px solid #999;
       text-align: center;
       font-family: 'Roboto','sans-serif';
       line-height: 30px;
       padding-left: 10px;
     }
</style>
JavaScript 

<script>
      function initMap() {
              var start_long = "104.4545";
var start_lat = "11.2132";
var s_longs = "104.4545";
        var directionsDisplay = new google.maps.DirectionsRenderer;
        var directionsService = new google.maps.DirectionsService;
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 14,
          center: {lat: 37.77, lng: -122.447}
        });
        directionsDisplay.setMap(map);
        calculateAndDisplayRoute(directionsService, directionsDisplay);
        document.getElementById('mode').addEventListener('change', function() {
          calculateAndDisplayRoute(directionsService, directionsDisplay);
        });
      }
      function calculateAndDisplayRoute(directionsService, directionsDisplay) {
              var start_long = "104.1252";
var start_lat = "11.1254";
var s_longs = parseFloat(start_long);
var s_lat = parseFloat(start_lat);
var end_long = "104.2358";
var end_lat = "11.1245";
var e_longs = parseFloat(end_long);
var e_lat = parseFloat(end_lat);
        var selectedMode = document.getElementById('mode').value;
        directionsService.route({
          origin: {lat:s_lat, lng: s_longs },  // Haight.
          destination: {lat:e_lat , lng: e_longs},  // Ocean Beach.
          // Note that Javascript allows us to access the constant
          // using square brackets and a string value as its
          // "property."
          travelMode: google.maps.TravelMode[selectedMode]
        }, function(response, status) {
          if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
          } else {
            window.alert('Directions request failed due to ' + status);
          }
        });
      }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=YOURAPIKEY&callback=initMap">
    </script>







21 July 2016

How to calculate distance on google maps with php?

- No comments
How to calculate distance on google from latitude and longitude. we need to get first point of latitude and longitude and point to end of our destination:

like from A-------------------------------------------> B (How many km?)



Here is the following code to solve this problem:

 
<?php

$lat1 = '11.570587';
    $lat2 = '11.570597';
    $lon1 = '104.898414';
    $lon2 = '104.898468';

    $dist   = acos(sin(deg2rad($lat1))
              * sin(deg2rad($lat2))
              + cos(deg2rad($lat1))
              * cos(deg2rad($lat2))
              * cos(deg2rad($lon1 - $lon2)));

    $dist   = rad2deg($dist);
    $miles  = (float) $dist * 69;

    // To get kilometers, multiply miles by 1.61
    $km     = (float) $miles * 1.61;

    // This is all displaying functionality
    $test  = sprintf("%0.2f",$miles).' miles' ;
    $display = sprintf("%0.2f",$km).' kilometers' ;

    echo $display ;
?>

By SharingBlog.xyz


14 July 2016

How to upgrade redmine to easy redmine in centos?

- No comments
Source Google for this image


1) Redmine Installer Ruby Gem

   $ gem install redmine-installer

2) Copy the zip file that download from easy redmine to centos server

3) Type command below:

   $ redmine upgrade PATH_TO_PACKAGE

  •    After type this command:


  1. Type yes
  2. /var/www/html/our_redmine_project   (Specific the directory that point to old redmine that you          already intalled)
  3. Type Database Password
4) make sure that webserver has Full access public, files, log, tmp folders
   - bundle install --without development test
   - bundle exec rake easyproject:install RAILS_ENV=production
   - service httpd restart


07 July 2016

How to get data from database to edit with dropdown select with php - codeigniter?



In Controller

public function edit_service(){
if($this->session->userdata('username')){
$data['title'] = "Edit Service";
$data['get_service'] = $this->ezefiber_model->edit_service();
$this->load->view("setting/pop_setting/edit_service",$data);

}else{
redirect('login', 'refresh');
}

}

In Model 

 function edit_service(){
      $this->db->where('type_id',$this->uri->segment(3));
      $query = $this->db->get('tblservice_pop');
      return $query->result();
   }
 
 In View

   <?php
$service = array(
'0' => "--Select--",
'example' => "example",
'Test' => "test"
);
?>

<?php foreach($get_service as $service) { ?>
 <select class="form-control" name="contract">
<?php foreach($contract as $select => $serviceview) {   ?>        
<option value="<?php echo $select ?>"
<?php if($select == $service->contract) { echo ' selected="selected"'; } ?>><?php echo $serviceview; ?></option>;
<?php }?>
</select>

<?php }?>





How to connect PostgreSQL with Codeigniter?

- No comments
As all of us know that postgrest sql is more bigger then mysql so it can store big data and more feature then mysql
one more thing is that postgrest sql are free it is open source

So how to connect postgrest sql with codeigniter??

1 ) Go to our codeigniter project and find config -> database.php

  Config it to:


2) Go to our web server xampp or warmp 

Go to edit on php.ini 

- un comment 



If warning need to add this code in our project