Category: PHP

  • Click on map and get Longitude -Latitude.

    Click on map and get Longitude -Latitude.

    How To Get Longitude – Latitude When Clicked On Map? <div id=”MyMap” style=”width:100%;height:500px;”></div> <script> function myMap() {   var mapCanvas = document.getElementById(“MyMap”);   var myCenter=new google.maps.LatLng(51.508742,-0.120850);   var mapOptions = {center: myCenter, zoom: 5};   var map = new google.maps.Map(mapCanvas, mapOptions);   google.maps.event.addListener(map,’click’, function(event) {     LocationMarker(map, event.latLng);   }); } function LocationMarker(map, location) {   var marker = new google.maps.Marker({     position: location,…

  • How to Calculate distance between two address using latitude and longitude.

    How to Calculate distance between two address using latitude and longitude.

    According To me it’s one of important requirement in many projects related to address. To Calculate distance between two address using latitude and longitude use this method. function LongLatDistance($Latitude1, $Longitude1, $Latitude2, $Longitude2) { $theta = $Longitude1 – $Longitude2; $miles = (sin(deg2rad($Latitude1))*sin(deg2rad($Latitude2)))+(cos(deg2rad($Latitude1))*cos(deg2rad($Latitude2)) * cos(deg2rad($theta))); $miles = acos($miles); $miles = rad2deg($miles); $result[‘miles’] = $miles * 60 *…

  • Convert PHP Array into JavaScript Array.

    Convert PHP Array into JavaScript Array.

    We can use PHP array in javascript. For this we have to convert PHP array ,whether the array type is a single or multidimensional or indexed or associative array,into JSON format Using php function json_encode().It’s mostly used when we have create API in PHP to transfer data form one server to other server because data…