{"id":258,"date":"2011-04-07T19:17:23","date_gmt":"2011-04-07T19:17:23","guid":{"rendered":"http:\/\/www.calvert.ch\/geodesix\/?page_id=258"},"modified":"2011-04-08T12:01:22","modified_gmt":"2011-04-08T12:01:22","slug":"talking-to-the-googlemaps-apis","status":"publish","type":"page","link":"https:\/\/www.calvert.ch\/geodesix\/help\/source-code\/talking-to-the-googlemaps-apis\/","title":{"rendered":"Talking to the GoogleMaps APIs"},"content":{"rendered":"<p>This subject is already extremely well documented <a href=\"http:\/\/code.google.com\/apis\/maps\/documentation\/javascript\/basics.html\" target=\"_new\">here<\/a>, so I&#8217;ll just point you to the relevant code.<\/p>\n<ul>\n<li>The call to GoogleMaps is at #7# in Geodesic.Resolve.Resolve.<\/li>\n<li>The resultant JSON object is made into a .Net object with <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.web.script.serialization.javascriptserializer.aspx\" target=\"_new\">System.Web.Script.Serialization.JavaScriptSerializer<\/a>.<br \/>\nThis is technically obsolete, but trying to figure out how to use <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.runtime.serialization.json.datacontractjsonserializer.aspx\" target=\"_new\">DataContractJsonSerializer<\/a>\u00a0was beyond my patience and JavaScriptSerializer #21# did the job perfectly.<\/li>\n<li>We parse the resultant object crudely in Geodesic.GetLocations.GetLocations #22# for geocode requests and Geodesic.GetRoutes.Getroutes #23# for Travel requests.<\/li>\n<li>Notice that in GetRoutes, we don&#8217;t parse the details of each step by default, they add nothing to the information we need for this application (simply the distance and the duration).<\/li>\n<li>Perhaps a word on <a href=\"http:\/\/code.google.com\/apis\/maps\/faq.html#geocoder_limit\" target=\"_new\">Google&#8217;s Terms Of Service<\/a>. In a nutshell, you may not make more than 2&#8217;500 geocode requests in a single 24-hour period. If you exceed this you will receive a 602 return code, as you will if you make requests too quickly in succession. GeodesiX respects this and slows down automatically if it receives a 602.<\/li>\n<li>The corollary is that information obtained from Google is &#8216;valuable&#8217; and we should at all costs avoid asking for it again. GeodesiX does this by saving the cache to a &#8216;very hidden&#8217; worksheet #24# and re-loading this cache when a workbook is re-opened #25#. This may be defensible, but it is barely in line with the T.O.S.<\/li>\n<li>The moral is: Please use this addin responsibly. I have no doubt that Google couldn&#8217;t care less if you geocode a few dozen locations occasionally and keep the answers. On the other hand, using GeodesiX to perform bulk geocoding is immoral, irresponsible and could potentially spoil a very useful service that benefits the majority.\n<p>Again, please play fairly and think of others.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This subject is already extremely well documented here, so I&#8217;ll just point you to the relevant code. The call to GoogleMaps is at #7# in Geodesic.Resolve.Resolve. The resultant JSON object is made into a .Net object with System.Web.Script.Serialization.JavaScriptSerializer. This is <a href='https:\/\/www.calvert.ch\/geodesix\/help\/source-code\/talking-to-the-googlemaps-apis\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":247,"menu_order":6,"comment_status":"open","ping_status":"closed","template":"momoframepage.php","meta":{"footnotes":""},"class_list":["post-258","page","type-page","status-publish","hentry","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/pages\/258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":4,"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/pages\/258\/revisions"}],"predecessor-version":[{"id":319,"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/pages\/258\/revisions\/319"}],"up":[{"embeddable":true,"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/pages\/247"}],"wp:attachment":[{"href":"https:\/\/www.calvert.ch\/geodesix\/wp-json\/wp\/v2\/media?parent=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}