zoukankan      html  css  js  c++  java
  • 利用google地图获取位置经纬度坐标的方法

    利用google地图获取位置经纬度坐标的方法

        public static void main(String[] args) throws UnsupportedEncodingException {
            String address = URLEncoder.encode("北京 香山公园","UTF-8");
            String url = "http://maps.google.cn/maps/geo?q="+address+"&output=csv&oe=utf8\\&sensor=true_or_false&           key=ABQIAAAAqaGKijD7euSpqDeVsNA85xTT3OL8VXjPlPTFW7n7OgOFwXoSnxT7IP1pHznaiGwWMvsEq_SkxvESLw";
            String content = Spider.getContent(url);
            String[] info = content.split(",");
            System.out.println(info[2]+","+info[3]);
        }

    一下为改过后的代码

        public static void main(String[] args) throws UnsupportedEncodingException {
            String address = URLEncoder.encode("北京 香山公园","UTF-8");
            String url = "http://maps.google.cn/maps/geo?q="+address+"&output=json&ie=utf8";
            String content = Spider.getContent(url);
            String[] info = content.split(",");
            System.out.println(info[2]+","+info[3]);
        }
    http://maps.google.cn/maps/geo?q=南京市&output=json&ie=utf8
    {
      "name": "南京市",
      "Status": {
        "code": 200,
        "request": "geocode"
      },
      "Placemark": [ {
        "id": "p1",
        "address": "中国江苏省南京市",
        "AddressDetails": {
       "Accuracy" : 4,
       "Country" : {
          "AdministrativeArea" : {
             "AdministrativeAreaName" : "江苏省",
             "Locality" : {
                "LocalityName" : "南京市"
             }
          },
          "CountryName" : "中国",
          "CountryNameCode" : "CN"
       }
    },
        "ExtendedData": {
          "LatLonBox": {
            "north": 32.3940135,
            "south": 31.8045247,
            "east": 119.0501690,
            "west": 118.4253323
          }
        },
        "Point": {
          "coordinates": [ 118.7968770, 32.0602550, 0 ]
        }
      } ]
    }
  • 相关阅读:
    mysql中文乱码解决方法
    MYSQL常用数据类型详解
    aspx中格式化时间的几种方式
    常用PHP中花括号使用规则详解
    jQuery对表单的操作
    jQuery Ajax 实例 ($.ajax、$.post、$.get)
    PHPEXCEL使用基础教程
    LINQ to XML 编程基础
    PHP获取URL各个部分的函数
    phpExcel常用方法详解大全
  • 原文地址:https://www.cnblogs.com/blogsme/p/2933362.html
Copyright © 2011-2022 走看看