-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetGeoLocation
50 lines (45 loc) · 15.9 KB
/
getGeoLocation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script type="text/javascript">
function getUberLocation(cabSegment){
var obj={"messageType":"OK","city":{"cityName":"chennai","currencyCode":"INR","countryIso2":"IN","geosurgeVersion":1,"vehicleViews":{"593":{"id":593,"uuid":"fbc0033d-5a1a-4f01-964c-0e4ea56b6e7e","parentId":null,"description":"UberBLACK","capacity":4,"maxFareSplits":4,"mapImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/map70px/map-black.png","width":70,"height":70}],"monoImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-black.png","width":114,"height":34}],"requestPickupButtonString":"REQUEST PICKUP HERE","setPickupLocationString":"SET PICKUP LOCATION","pickupEtaString":"PICKUP TIME IS APPROXIMATELY {string}","fare":{"id":753,"base":"₹ 100","baseValue":100,"perDistanceUnit":"₹ 18","distanceUnit":"km","perMinute":"₹ 2","speedThresholdMps":5,"minimum":"₹ 150","cancellation":"₹ 150","type":"TimeAndDistance"},"fareDetailsUrl":null,"allowFareEstimate":true,"noneAvailableString":"NO CAR IS AVAILABLE","allowCredits":true,"allowCreditsError":"dynamic_key.VehicleView.allow_credits_error.593","permittedPaymentMethods":null,"permittedPaymentMethodsError":"dynamic_key.VehicleView.permitted_payment_methods_error.593","addPermittedPaymentMethodButtonTitle":"dynamic_key.VehicleView.add_permitted_payment_method_button_title.593","allowedToSurge":true,"displayName":"UberBLACK","isCashOnly":false,"isInspecting":false,"paymentDisclosureString":null,"groupId":null,"routelineDisplay":[],"enableVehicleInventoryView":false,"surge":{"fareId":172337172,"fareUuid":"84e186bc-2f76-40ea-be87-fc6b3e9b5f50","multiplier":1.2,"expirationTime":120,"base":"₹120","perDistanceUnit":"₹21.60","distanceUnit":"km","perMinute":"₹2.40","minimum":"₹180","cancellation":"₹180","dropNotification":{"defaultExpirationTime":1800,"enabled":true}}},"1581":{"id":1581,"uuid":"16aac0ac-ece9-45b0-b717-a325d7b058ff","parentId":null,"description":"uberX","capacity":4,"maxFareSplits":4,"mapImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/map70px/map-uberx.png","width":70,"height":70}],"monoImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png","width":114,"height":34}],"requestPickupButtonString":"REQUEST {string}","setPickupLocationString":"SET PICKUP LOCATION","pickupEtaString":"PICKUP TIME IS APPROXIMATELY {string}","fare":{"id":1842,"base":"₹ 40","baseValue":40,"perDistanceUnit":"₹ 9","distanceUnit":"km","perMinute":"₹ 1","speedThresholdMps":5,"minimum":"₹ 80","cancellation":"₹ 100","type":"TimeAndDistance"},"fareDetailsUrl":null,"allowFareEstimate":true,"noneAvailableString":"NO CARS AVAILABLE","allowCredits":true,"allowCreditsError":"dynamic_key.VehicleView.allow_credits_error.1581","permittedPaymentMethods":null,"permittedPaymentMethodsError":"dynamic_key.VehicleView.permitted_payment_methods_error.1581","addPermittedPaymentMethodButtonTitle":"dynamic_key.VehicleView.add_permitted_payment_method_button_title.1581","allowedToSurge":true,"displayName":"uberX","isCashOnly":false,"isInspecting":false,"paymentDisclosureString":null,"groupId":null,"routelineDisplay":[],"enableVehicleInventoryView":false},"2019":{"id":2019,"uuid":"c58b6622-0be7-4de1-ad60-a9c4d6f4eaa5","parentId":null,"description":"uberGO","capacity":4,"maxFareSplits":4,"mapImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/map70px/map-ubergo.png","width":70,"height":70}],"monoImages":[{"url":"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-ubergo.png","width":114,"height":34}],"requestPickupButtonString":"REQUEST {string}","setPickupLocationString":"SET PICKUP LOCATION","pickupEtaString":"PICKUP TIME IS APPROXIMATELY {string}","fare":{"id":2323,"base":"₹ 40","baseValue":40,"perDistanceUnit":"₹ 8","distanceUnit":"km","perMinute":"₹ 1","speedThresholdMps":5,"minimum":"₹ 80","cancellation":"₹ 80","type":"TimeAndDistance"},"fareDetailsUrl":null,"allowFareEstimate":true,"noneAvailableString":"NO CARS AVAILABLE","allowCredits":true,"allowCreditsError":"dynamic_key.VehicleView.allow_credits_error.2019","permittedPaymentMethods":null,"permittedPaymentMethodsError":"dynamic_key.VehicleView.permitted_payment_methods_error.2019","addPermittedPaymentMethodButtonTitle":"dynamic_key.VehicleView.add_permitted_payment_method_button_title.2019","allowedToSurge":true,"displayName":"uberGO","isCashOnly":false,"isInspecting":false,"paymentDisclosureString":null,"groupId":null,"destinationEntry":"optional","routelineDisplay":[],"enableVehicleInventoryView":false}},"vehicleViewsOrder":[593,1581,2019],"defaultVehicleViewId":1581,"messages":[{"id":"mobile_message_9002","eTag":4182488158}]},"client":{"countryId":77,"email":"[email protected]","firstName":"Nivas","lastName":"SV","id":6489709,"uuid":"2d1a0502-f045-448c-82d2-c0d934b3a681","isAdmin":false,"mobile":"+91 95 00 271589","mobileDigits":"9500271589","mobileCountryCode":"+91","mobileCountryId":77,"mobileCountryIso2":"IN","hasConfirmedMobile":true,"hasAmericanMobile":false,"hasToOptInSmsNotifications":false,"pictureUrl":"https://d1w2poirtb3as9.cloudfront.net/f8a1a9842fb4b3bebbb5.jpeg","role":"client","token":"bb5d0d26e9b66eb449b9677970d8d2e2","referralCode":"g0kit","referralUrl":"https://www.uber.com/invite/g0kit","creditBalances":[{"amountString":"₨17.90","displayName":"INR"}],"tripBalances":[],"paymentProfiles":[{"id":6984729,"cardType":"MasterCard","cardBin":"539998","useCase":"personal","cardNumber":"0123","cardExpiration":"2021-01-01T00:00:00+00:00","cardExpirationEpoch":1609459200000,"billingZip":"600100","billingCountryIso2":"IN","tokenType":"braintree","accountName":"0123","uuid":"1d062aa7-dd27-43c3-ba85-b3122fb9f303"},{"id":24988749,"cardType":"Paytm","cardBin":"other","useCase":"personal","cardNumber":"payt","cardExpiration":"2015-11-26T13:35:46.864000+00:00","cardExpirationEpoch":1448544946864,"tokenType":"paytm","uuid":"30bf9a2f-6a96-4222-a75a-82985da97855"}],"lastSelectedPaymentProfileIsGoogleWallet":false,"inactivePaymentProfiles":[],"lastSelectedPaymentProfileId":24988749,"lastSelectedPaymentProfileUUID":"30bf9a2f-6a96-4222-a75a-82985da97855","status":"Looking","lastRequestNote":null,"lastRequestMsg":null,"promotion":"₹300","fareSplitFeeString":"Each rider will be charged a ₹ 5 fare split fee.","isApplePayAuthenticated":false,"reverseGeocode":{"id":"2e0d0a71-b60c-4af6-b7b1-9d6825cab0a4","latitude":12.970305,"longitude":80.244918,"short":"North Veeranam Salai, Kodandarama Nagar, Perungudi","long":"North Veeranam Salai, Kodandarama Nagar, Perungudi, Chennai, Tamil Nadu 600078, India","nickname":null},"thirdPartyIdentities":{}},"appConfig":{"disableAnalyticsV2":false,"rider":{"etaProvider":"none","routeProvider":"none","tripTrayStyle":"enabled","enableSafetyNet":true,"enableSosEventAlert":true,"locationSearch":"rtapi","androidNotifications":true,"locationSearchPresentationStyle":"highlightAfter","addFundsDefaultValues":{"denomination1":200,"denomination2":500,"denomination3":1000},"sliderStyle":"stacked","enablePayTM":true,"newProductPanelEnabled":true,"disablePayTM":false,"enableIndiaInternationalCcCopy":true,"disableiOSNewShareScreen":true,"favoriteLocations":"homeAndWork","favoriteLocationDistanceConstraints":{"minimumDropoffDistanceInMeters":300,"maximumDropoffDistanceInMeters":120000,"maximumPickupDistanceInMeters":1600},"fareEstimateFlowVariant":"rateCardVariant2OldConfirmation","enableSosIndiaRider":false,"enableUnison":true,"disableTripStatusViewUpdates":false},"enableAnalyticsV1":false,"disableTripHistoryScreenRider":false,"disableNewSupportFlowRider":false,"disableSupportPostTripRider":false,"disableTripHistoryScreenDriver":false,"disableNewSupportFlowDriver":false,"disableSupportPostTripDriver":false,"enableSosIndiaRider":true,"driver":{"disableReferrals":false,"request":{"WayBill":"rtapi"},"tagTokens":"6OAkzjDQ/VwkgjfFGngFNiYISA98uSbnAUL57xpEVpzsswaGVM+09+yOtqCjNreG/1DHliNo2610Is417rx6j8n95gGF6vUDqpFg8GT3skiAtoloixBPi7kyPI/vFcK/lYWRIJPzOICdLhihHCkitPVfc1pqtGZsvHB/Y6ZueUOCZs4g7nB6jbaWWlx3lyfmS387yCf9BI6kMQN/YJ9CRr1BqvRdQhJbxrMOi66JazQL/F9qaGCXCGKqDotXzfAN","enableExplicitSecondaryDispatchAccept":true},"emergencyNumber":100,"beginEndTripConfirmation":"slider","requireOSIntegrity":true,"disableProximityDetection":false,"features":{"disableFeatureTest":true},"abtesting":{"test_flipr_ab3":{"treatment_group_serial":0,"treatment_group_name":"control"}},"enableMusicBar":true,"disableSpotifyLinkAndUnlink":false,"enableExperiments":false,"backgroundTickle":{},"enableExperimentsRider":true,"enableExperimentsPartner":true,"sendExplicitSecondaryDispatchAccept":true,"delaySuspendForPing":false,"useSchedulePingResponse":false,"track_location_on_start":{}},"session":{"sessionHash":"0006dd4f-72e8-4380-be05-ba743993a089"},"mapFittingMobileAppDelayWindowMs":36000,"nearbyVehicles":{"593":{"vehiclePaths":{"5811cb41-a19f-4cc3-9dac-67def760f6ce":[{"epoch":1431158839881,"latitude":12.95788,"longitude":80.24255,"course":-53},{"epoch":1431158867926,"latitude":12.95788,"longitude":80.24255,"course":-53}]},"etaString":"6 minutes","etaStringShort":"6 mins","minEta":6},"1581":{"vehiclePaths":{"5811cb41-a19f-4cc3-9dac-67def760f6ce":[{"epoch":1431158839881,"latitude":12.95788,"longitude":80.24255,"course":-53},{"epoch":1431158867926,"latitude":12.95788,"longitude":80.24255,"course":-53}],"aa9c3635-5a5e-48ef-9138-bf513df30485":[{"epoch":1431158651006,"latitude":12.97702,"longitude":80.24389,"course":167},{"epoch":1431158674013,"latitude":12.97702,"longitude":80.24389,"course":167}],"1a2f6055-58b6-4666-9b81-4a7ef006d5db":[{"epoch":1431158836698,"latitude":12.98159,"longitude":80.26378,"course":-173},{"epoch":1431158871695,"latitude":12.98159,"longitude":80.26378,"course":-173}]},"etaString":"6 minutes","etaStringShort":"6 mins","minEta":6},"2019":{"vehiclePaths":{"1a53401f-6488-48a1-bdda-44e8aac382ae":[{"epoch":1431158839872,"latitude":12.9809,"longitude":80.25931,"course":3},{"epoch":1431158843154,"latitude":12.98111,"longitude":80.25932,"course":2},{"epoch":1431158844872,"latitude":12.98122,"longitude":80.25932,"course":2},{"epoch":1431158849872,"latitude":12.98155,"longitude":80.25933,"course":2},{"epoch":1431158852528,"latitude":12.98172,"longitude":80.25934,"course":2},{"epoch":1431158854869,"latitude":12.98187,"longitude":80.25935,"course":2},{"epoch":1431158858870,"latitude":12.98209,"longitude":80.25936,"course":2},{"epoch":1431158860613,"latitude":12.98219,"longitude":80.25936,"course":3},{"epoch":1431158862870,"latitude":12.98232,"longitude":80.25937,"course":3},{"epoch":1431158866872,"latitude":12.98253,"longitude":80.25938,"course":3},{"epoch":1431158867951,"latitude":12.98259,"longitude":80.25938,"course":5},{"epoch":1431158871873,"latitude":12.98281,"longitude":80.2594,"course":5}],"7b951cf9-c4f2-4e3d-8611-ebbdb39cb6cc":[{"epoch":1431158823792,"latitude":12.97643,"longitude":80.22209,"course":-107},{"epoch":1431158871801,"latitude":12.97643,"longitude":80.22209,"course":-107}]},"etaString":"12 minutes","etaStringShort":"12 mins","minEta":12}}};
var obj = obj.nearbyVehicles;
var names = Object.keys(obj);
var c=0;
var geoPosition = [];
for ( var x in obj) {
var name = names[c];
c=c+1;
var temp = obj[x].vehiclePaths;
for ( var y in temp) {
var csd=temp[y];
csd = csd[csd.length-1];
if(name==cabSegment){
var lat = csd.latitude;
var lon = csd.longitude;
geoPosition.push({"lat":lat,"lon":lon});
}
}
}
console.log(geoPosition);
}
function getOlaLocation(){
var obj={"status":"SUCCESS","ip_address":"192.168.192.100","request_type":"CAB_INFO","state_id":1,"cab_availability":true,"response_category":"economy_sedan","cab_categories":[{"id":"compact","display_name":"Mini","cab_availability":true,"ride_now_enable":true,"ride_later_enable":true,"distance":{"unit":"METER","value":2},"duration":{"unit":"MINUTE","value":18}},{"id":"economy_sedan","display_name":"Sedan","cab_availability":true,"ride_now_enable":true,"ride_later_enable":true,"distance":{"unit":"METER","value":2410},"duration":{"unit":"MINUTE","value":14}},{"id":"luxury_sedan","display_name":"Prime","cab_availability":false,"display_text":"No Prime nearby.","ride_now_enable":false,"ride_later_enable":false},{"id":"local_auto","display_name":"Auto","cab_availability":true,"display_text":"Now pay for auto rides with Ola Money!","ride_now_enable":true,"ride_later_enable":false,"distance":{"unit":"METER","value":2},"duration":{"unit":"MINUTE","value":3}}],"kp_categories":[],"city_taxi_categories":[{"id":"economy_sedan","name":"economy_sedan","display_name":"Sedan"},{"id":"compact","name":"compact","display_name":"Mini"}],"alloted_cab_direction":{},"cabs":[{"id":"651c429a-8374-54c5-4e6a-551259125e53","lat":12.9781116,"lng":80.2250916,"category_id":"economy_sedan"},{"id":"96b1134a-d81d-b840-c396-551f7508731a","lat":12.9855969,"lng":80.2236811,"category_id":"economy_sedan"},{"id":"a1df65c0-92e3-9b0a-01ad-54fea88d37d4","lat":12.97903,"lng":80.2187916,"category_id":"economy_sedan"},{"id":"f2e4fa4e-c4d6-585a-3d89-54c3285d2509","lat":12.9761906,"lng":80.2624687,"category_id":"economy_sedan"},{"id":"854ed5e2-1383-9fda-9531-549d7e5d2f1d","lat":12.9904783,"lng":80.22039,"category_id":"economy_sedan"},{"id":"744684b7-4794-c0b3-1561-55348604c28e","lat":12.9899469,"lng":80.2188757,"category_id":"economy_sedan"}],"city_tag":"CHENNAI","user_city":"CHENNAI","location_tag":"default","booking_status":"NO_BOOKING","emergency_number_verified":false,"next_call_after":11,"recharge_screen":true,"recharge_text":"","delivery_recharge_screen":false,"delivery_recharge_text":"","disable_ride_later_delivery":false,"delivery_recharge_header":"Insufficient Balance"};
var cabs = obj.cabs;
var geoPosition = [];
for ( var x in cabs) {
var carObj = cabs[x];
if(carObj.category_id=="economy_sedan")
geoPosition.push({"lat":carObj.lat,"lon":carObj.lng});
}
console.log(geoPosition);
}
function getTaxi4SureLocation(){
var obj = {"status":"success","message":"No cabs available within 7 km","error_desc":"","error_code":"","response_data":{"data":[{"distance":"2.28","uuid":"102111af-d97b-478f-8a7b-3a28ef3cf1ab","Distance":"2.28","carType":"Sedan","longitude":"80.2577541","duration":14,"Time":1423833661837,"latitude":"12.9853766","city":"Chennai"},{"distance":"2.45","uuid":"a6522373-66d5-4bf8-aa1d-5851cc16a157","Distance":"2.45","carType":"Hatchback","longitude":"80.2403926","duration":15,"Time":1429703296477,"latitude":"12.9478934","city":"Chennai"}],"carTypes":[{"carType":"hatchback","dashboardIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/hatchback_v1.png","mapIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/hatchback_map_v1.png","iconVersion":1,"carName":"Hatchback","isDefault":false,"showPickNow":true,"showPickLater":true,"showDiscountCoupon":true,"enableDestination":true,"enableAirport":true,"useWallet":true,"noVehicleMessage":"No hatchback available nearby. Try Pick Later."},{"carType":"sedan","dashboardIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/sedan_v1.png","mapIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/sedan_map_v1.png","iconVersion":1,"carName":"Sedan","isDefault":false,"showPickNow":true,"showPickLater":true,"showDiscountCoupon":true,"enableDestination":true,"enableAirport":true,"useWallet":true,"noVehicleMessage":"No sedan available nearby. Try Pick Later."},{"carType":"suv","dashboardIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/suv_v1.png","mapIconUrl":"https://s3-ap-southeast-1.amazonaws.com/assets.taxiplease.in/consumerapp/images/android/xxhdpi/suv_map_v1.png","iconVersion":1,"carName":"SUV","isDefault":true,"showPickNow":false,"showPickLater":true,"showDiscountCoupon":true,"enableDestination":true,"enableAirport":true,"useWallet":true,"noVehicleMessage":"No suv available nearby. Try Pick Later."}],"vehicle_hash":"d7c7b6033f937a85c11e75eda431c395"}};
var cabData = obj.response_data.data;
var geoPosition = [];
for ( var x in cabData) {
var temp = cabData[x];
geoPosition.push({"lat":temp.latitude,"lon":temp.longitude});
}
console.log(geoPosition);
}
</script>