何为第三方支付平台 我们把时间往前推15年,1999年的时候国内的电子商务开始起步,一些电商网站开始运行。理论上人们可以通过网络进行支付、购物。用户在网上下单,支 付,然后商家收到钱后发货,用户收到货物感觉非常嗨皮,一次美好的网购旅程结束了。但有时并不那么嗨皮,这种流程因为在支付和收货之间存在时间和空间上的 距离,那么问题就来了,不是挖掘技术哪家强,而是用户和商家难以在彼此信任的问题上达成一致,用户担心我给了钱,商家不发货;商家担心如果先发货,用户不 付钱。为了解决这种尴尬,第三方支付平台诞生了。 第三方支付平台通俗的讲就是作为一个中介,用户先把钱划给第三方平台,第三方平台暂时保管,并通知商家发货,商家将货物发送给用户,用户收货满意后,通知 支付平台,第三方支付平台把钱划给商家,如果用户收货后不满意,就将货物退回,第三方平台将钱返还给用。就这样后来陆续产生了很多第三方支付平台,支付 宝、财付通、快钱等是经过洗牌之后(支付牌照的颁发),目前规模比较大的第三方支付平台,顺便说一下,建设第三方支付平台门槛高、风险大、竞争激烈,首先…
May 25, 2015
javascript 通过地址获取经纬度 get lat long from address
地图版:
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title> - demo</title> <script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script> <script src="http://maps.google.com/maps/api/js?libraries=places&sensor=true"></script> <script type='text/javascript'>//<![CDATA[ $(window).load(function() { $(function () { var lat = 44.88623409320778, lng = -87.86480712897173, latlng = new google.maps.LatLng(lat, lng), image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png'; //zoomControl: true, //zoomControlOptions: google.maps.ZoomControlStyle.LARGE, var mapOptions = { center: new google.maps.LatLng(lat, lng), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP, panControl: true, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, position: google.maps.ControlPosition.TOP_left } }, map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions), marker = new google.maps.Marker({ position: latlng, map: map, icon: image }); var input = document.getElementById('searchTextField'); var autocomplete = new google.maps.places.Autocomplete(input, { types: ["geocode"] }); autocomplete.bindTo('bounds', map); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(autocomplete, 'place_changed', function (event) { infowindow.close(); var place = autocomplete.getPlace(); if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(17); } moveMarker(place.name, place.geometry.location); $('.MapLat').val(place.geometry.location.lat()); $('.MapLon').val(place.geometry.location.lng()); }); google.maps.event.addListener(map, 'click', function (event) { $('.MapLat').val(event.latLng.lat()); $('.MapLon').val(event.latLng.lng()); infowindow.close(); var geocoder = new google.maps.Geocoder(); geocoder.geocode({ "latLng":event.latLng }, function (results, status) { console.log(results, status); if (status == google.maps.GeocoderStatus.OK) { console.log(results); var lat = results[0].geometry.location.lat(), lng = results[0].geometry.location.lng(), placeName = results[0].address_components[0].long_name, latlng = new google.maps.LatLng(lat, lng); moveMarker(placeName, latlng); $("#searchTextField").val(results[0].formatted_address); } }); }); function moveMarker(placeName, latlng) { marker.setIcon(image); marker.setPosition(latlng); infowindow.setContent(placeName); //infowindow.open(map, marker); } }); }); </script> </head> <body> Address: <input id="searchTextField" type="text" size="50" style="text-align:%20left;width:357px;direction:%20ltr;"> <br> latitude:<input name="latitude" class="MapLat" value="" type="text" placeholder="Latitude" style="width:%20161px;" disabled> longitude:<input name="longitude" class="MapLon" value="" type="text" placeholder="Longitude" style="width:%20161px;" disabled> <div id="map_canvas" style="height:%20350px;width:%20500px;margin:%200.6em;"></div> </body> </html>
参考:http://stackoverflow.com/a/14051235/4484798
简约版
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <textarea id="txtAddress" rows="3" cols="25"></textarea> <br /> <input type="button" onclick="GetLocation()" value="Get%20Location" /> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> <!-- function GetLocation() { var geocoder = new google.maps.Geocoder(); var address = document.getElementById("txtAddress").value; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { var latitude = results[0].geometry.location.lat(); var longitude = results[0].geometry.location.lng(); alert("Latitude: " + latitude + "nLongitude: " + longitude); } else { alert("Request failed.") } }); }; //--> </script> </body> </html>
通过经纬度获取地址
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> Latitude: <input type="text" id="txtLatitude" value="18.92488028662047" /> Latitude: <input type="text" id="txtLongitude" value="72.8232192993164" /> <input type="button" value="Get%20Address" onclick="GetAddress()" /> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function GetAddress() { var lat = parseFloat(document.getElementById("txtLatitude").value); var lng = parseFloat(document.getElementById("txtLongitude").value); var latlng = new google.maps.LatLng(lat, lng); var geocoder = geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { alert("Location: " + results[1].formatted_address); } } }); } </script> </body> </html>
或者直接使用 https://maps.googleapis.com/maps/api/geocode/json?address=changzhi
参考 https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
demo:http://sources.ikeepstudying.com/google-distance/latng.php
原文:javascript 通过地址获取经纬度 get lat long from address