/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ const url = 'https://pencarian-puskesmas.kicap-karan.com/'; // const url = 'https://192.168.43.125/puskesmas_admin/' function $_GET(param) { var vars = {}; window.location.href.replace( location.hash, '' ).replace( /[?&]+([^=&]+)=?([^&]*)?/gi, // regexp function( m, key, value ) { // callback vars[key] = value !== undefined ? value : ''; } ); if ( param ) { return vars[param] ? vars[param] : null; } return vars; } var id_warkop = $_GET('id'); var kordinat_a = $_GET('kordinat').split(',')[0]; var kordina_b = $_GET('kordinat').split(',')[1]; function klik_peta(){ // window.open('https://www.google.com/maps/dir/?api=1&destination='+kordinat_a+','+kordina_b+'&travelmode=driving&waypoints=-4.02091,119.62752|-4.05714,119.65665', '_system'); window.open('https://www.google.com/maps/dir/?api=1&destination='+kordinat_a+','+kordina_b+'&travelmode=driving', '_system'); return false; } // console.log(kordinat_sekarang) function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // Wait for the deviceready event before using any of Cordova's device APIs. // See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready document.addEventListener('deviceready', onDeviceReady, false); function onDeviceReady() { // Cordova is now initialized. Have fun! // alert("sukses"); // ambil_peta(); // console.log('Running cordova-' + cordova.platformId + '@' + cordova.version); // document.getElementById('deviceready').classList.add('ready'); } function blockUI(){ $.blockUI({ message: "Aktifkan \n GPS", css: { border: 'none', padding: '15px', backgroundColor: '#000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .5, color: '#fff' } }); } if ('permissions' in navigator) { navigator.permissions.query({name:'geolocation'}).then(function(result) { if (result.state == 'granted') { report(result.state); // geoBtn.style.display = 'none'; $.unblockUI(); } else if (result.state == 'prompt') { blockUI(); report(result.state); // geoBtn.style.display = 'none'; // navigator.geolocation.getCurrentPosition(revealPosition,positionDenied,geoSettings); } else if (result.state == 'denied') { report(result.state); // geoBtn.style.display = 'inline'; blockUI(); } result.onchange = function() { // report(result.state); if (result.state == 'granted') { $.noConflict(); $.unblockUI(); }else{ blockUI(); } } }); } function report(state) { // console.log('Permission ' + state); } function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function initMap() { // console.log($("#kordinat_warkop").val()) var directionsDisplay = new google.maps.DirectionsRenderer; var directionsService = new google.maps.DirectionsService; var map = new google.maps.Map(document.getElementById("map1"), { zoom: 7, center: new google.maps.LatLng(-4.0127077,119.6031278), mapTypeControl: false, mapTypeId: "hybrid" }); directionsDisplay.setMap(map); // directionsDisplay.setPanel(document.getElementById('right-panel')); // var pointb = new google.maps.LatLng(-3.9935955,119.6615051); var pointa = new google.maps.LatLng(kordinat_a , kordina_b); // calculateAndDisplayRoute(directionsService, directionsDisplay,pointa,pointb); navigator.geolocation.watchPosition((position) => { // console.log(position.coords.latitude, position.coords.longitude); var latitude = position.coords.latitude; var longitude = position.coords.longitude; var lat = 0; var long = 0; if (lat != latitude && long != longitude) { calculateAndDisplayRoute(directionsService, directionsDisplay,pointa,new google.maps.LatLng(latitude , longitude)) console.log(latitude) console.log(longitude) } },(err)=>{ // console.log(err); // $.noConflict(); $.unblockUI(); swal({ // title: "Submit Keperluan ?", text: "Aktifkan GPS untuk melihat rute", icon: "warning", buttons: { cancel: false, confirm: true, }, // dangerMode: true, }) .then((hehe) =>{ location.reload(); }); },{enableHighAccuracy: true}); } function calculateAndDisplayRoute(directionsService, directionsDisplay,pointa,pointb) { var start = pointa; var end = pointb; // console.log(directionsService.route()); directionsService.route({ origin: start, destination: end, travelMode: "DRIVING" }, function(response, status) { if (status === "OK") { // jQuery.noConflict() // $.unblockUI(); directionsDisplay.setDirections(response); } else { if (status === 'ZERO_RESULTS') { // jQuery.noConflict() $.blockUI({ message: '
'+faskesnya[i].nama+'
Jam Buka : '+faskesnya[i].buka+'
Jam Tutup : '+faskesnya[i].tutup+'