首页 \ 问答 \ 使用PHP解析Googlemaps(Using PHP to parse Googlemaps)

使用PHP解析Googlemaps(Using PHP to parse Googlemaps)

我有一个网站,我屏幕上刮掉GoogleMaps以获得从一个点到另一个点的行车距离。 它没有被大量使用(每周最多20次请求),但Google最近的升级破坏了这一功能。

我以前用这个:

$url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); if(preg_match('!(\d+).*?.*?(\d+)[^\d]*(\d*)!si', $data, $matches))

它会返回行驶距离和总时间。 新版本的GoogleMaps破坏了这一功能,我正试图找到一种处理新API的方法。


I have a site that I screen-scrape off GoogleMaps to get the driving distance from one point to another. It isn't heavily used (20 requests per week max), but Google's recent upgrade broke this functionality.

I used to use this:

$url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); if(preg_match('!(\d+).*?.*?(\d+)[^\d]*(\d*)!si', $data, $matches))

And it would return driving distance and total time. The new version of GoogleMaps broke this functionality and I'm trying to figure out a way to deal with the new API.


原文:https://stackoverflow.com/questions/3727799
更新时间:2023-11-24 14:11

最满意答案

Compass允许您使用内inline-image帮助程序inline-image ...

background-image: inline-image("/assest/svg/test.svg");

Compass allows you to inline the image with the inline-image helper...

background-image: inline-image("/assest/svg/test.svg");

相关问答

更多
  • 不,内联SVG被视为图像,而图像是被替换的元素 ,不允许生成内容 。 严格地说,我认为它是不确定的。 一般来说, CSS 2.1只是谈论“图像,嵌入式文档和小程序”, HTML标准定义了它的图像,而不是明确的SVG。 No, inline SVG is treated as an image, and images are replaced elements which are not allowed to have generated content. Strictly speaking, I think ...
  • 可能这样会好的:
    是的,这是可能的。 尝试这个: body { background-image: url("data:image/svg+xml;utf8,
  • y版本有两个问题。 a)svg元素没有名称空间(它在x版本中),但在y版本中它还需要xlink名称空间,因为图像href属性在xlink名称空间中。 b)SVG中的图像是外部的。 css背景是一个图像本身,因此它引用的任何SVG都无法加载外部资源。 因此,您需要对内部图像数据进行URI编码,然后对外部SVG进行uri编码(从而对内部图像数据进行双重编码) 所以你需要这样的东西...... var y = encodeURIComponent('
    我发现快速破解,用svg的文本替换svg以强制重绘。 $.fn.xml = function() { return (new XMLSerializer()).serializeToString(this[0]); }; $.fn.SVGRedraw = function() { return $(this.xml()).replaceAll(this); }; I found quick hack, to replace svg with text of the svg to forc ...
  • 这是一个XML文件,因此最小化您需要告诉浏览器它是一个SVG文件。 您可以通过将xmlns属性添加到根元素来完成此操作。
  • 使用Document.createElementNS创建SVG元素 直接从JavaScript创建时,您需要使用Document.createElementNS创建svg元素: var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 您渲染路径的示例: function creel(tagname, id, cla, attrs) { // USE createElementNS HERE var ...
  • Compass允许您使用内inline-image帮助程序inline-image ... background-image: inline-image("/assest/svg/test.svg"); Compass allows you to inline the image with the inline-image helper... background-image: inline-image("/assest/svg/test.svg");
  • 您可以使用Snap轻松创建您要查找的内容。 在下面的代码片段中,我添加了元素的所有必需属性和类型,并使用.el()创建了一个svg元素 el的语法是 Paper.el(name,attr) Name是您要创建的元素,例如line,circle,path等,attr是您要添加的属性。 在下面的数据中,我通过指定其属性创建了两行和一个圆。 我还添加了填充和描边 var data = [ { type:"line", attrs:{ x1:0, x2:0, y1:0, ...
  • module.loaders = ... { test: /\.(svg)$/, loader: 'raw-loader' } 这是因为你有内联svg。 参考 module.loaders = ... { test: /\.(svg)$/, loader: 'raw-loader' } This is because you are having the inline svg. Ref

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)