Analysis of geocoding and ding on Google Maps

Source: Internet
Author: User
Tags polyline
Analysis of geocoding and ding on Google Maps

In fact, for the geocoding of Google Maps
And now you can use the Chinese Geographic Name to locate the map (it seems to be detailed at the county level ). In the end, Google map uses mapabc, and its geocoding
And directions are mapabc.

Geocoding)

First, we request an address in ditu.google.com. For example, "Nantong ".
Http://ditu.google.com/maps? F = Q & HL = zh_cn & Q = Nantong & Output = JS pay attention to the following
Output = JS indicates that the request is output in JS format. View the source code and find the JS Code:

Function onload (){
VaR W = Window. parent;
W = W. parent;
W. loadvpage ({
Title: "Nantong-Google map ",
Vartitle: "",
URL: "/maps? F = Q/x26hl = zh_cn/x26q = % E5 % 8d % 97% E9 % 80% 9A/x26ie = utf8 ″,
Urlviewport: false,
EI: "yzzeroihmaekjqpc1yd_ag ",
Form: {selected: "Q", Q: {q: "Nantong"}, L: {q: "", near: "Nantong"}, D: {saddr: "", daddr: "Nantong"}, geocode: "", G: {q: "Nantong"}, K: {q: "Nantong "}},
Query: {type: "G "},
Stickyflags: {hl: "zh_cn "},
Viewport: {center: {Lat: 0, LNG: 0}, span: {Lat: 0, LNG: 0}, maptype: ""},
Resolvedpoiid: false,
Mabccenter: {ID: "be000005cb", title: "Nantong City, Jiangsu Province", gridcode: "4820061911", bottomleftid: "bf00000b96", toprightid: "bf00000b97", Zoom: "9 ″},
Modules: [""],
Overlays: {sxcar: false, markers: [{ID: "ADDR", mapabcpoiid: "be000005cb", Lat: 0, LNG: 0, image: "Success? F = Q/x26hl = ZH-CN/x26q = % E5 % 8d % 97% E9 % 80% 9A/x26ie = utf8/x26sll = 32.011111, 120.866667/x26sspn = 1.700295, 2.005194/x26latlng =/x26ei = Bytes/x26sig2 = zh9hy_q1_vimybylm8abvw ", addresslines: [" Nantong, Jiangsu Province "], log:" eamqbg ", icon:" ADDR ", infowindow: {type: "html", basics: "/x3cdiv transclude =/" IW/"/x3e/x3c/Div/x3e", _: 0}, geocode: "", OFID: "0 x 35b178472e21ea0b: 0x96250a629064a256"}]},
Panel: "...",
Panelstyle: "",
Panelid: 0,
Printheader: "...",
Addressbook :{......},
Signed_in: True
                    }, “state”);
}

Here we mainly want to get the markers in the overlays attribute.
This queue does not exist if the query has no results. However, you may find that there is no latitude and longitude we need here, which is Lat: 0, LNG: 0, but it doesn't matter. Generally, every marker
The object has a mapabcpoiid attribute. This is a geographical Decoding of mapabc. We will use this number to get the latitude and longitude of mapabc.

In this example, we get "be000005cb ". Below we will use a mapabc interface http://mapgoogle.mapabc.com/mapabcpoi? The
The PCO parameter is the encoding we just obtained. See what the results will be! Right, we get a notpcostrbase64 =
Mtiwljg3mdqzncwzmi4wmte2mjm =. Notpcostrbase64
Is a base64 encoded value. This encoding is the latitude and longitude we need. After base64 decoding, It is the latitude and longitude we want for 120.870434 and 32.011623.

Route (directions)

This principle is basically the same as that of geocoding. Make a GET request in ditu.google.com. Http://ditu.google.com/maps? F = D & HL = zh_cn & geocode = & saddr = Tongzhou city, Nantong City, Jiangsu Province & daddr = Nantong City, Jiangsu Province & Output = JS
This means that the value of F is different, and there is an additional starting point (saddr) and ending point (daddr), which also requires output = Js. We get the following JS Code:

Function onload (){
VaR W = Window. parent;
W = W. parent;
W. loadvpage (
{
Title: "From: Nantong City, Jiangsu Province to: Nantong City, Jiangsu Province-Google map ",
Vartitle: "",
URL: "/maps? F = D/x26hl = zh_cn/x26geocode =/x26saddr = % E6 % B1 % 9f % E8 % 8B % 8f % E7 % 9C % 81% E5 % 8d % 97% E9 % 80% 9A % E9 % 80% 9A % E5 % B7 % 9e % E5 % B8 % 82/x26daddr = % E6 % B1 % 9f % E8 % 8B % 8f % E7 % 9C % 81% E5 % 8d % 97% E9 % 80% 9A/x26ie = utf8 ″,
Urlviewport: false,
EI: "nknerojxn6ocjqpxyl2faw ",
Form: {selected: "D", Q: {q: "From: Nantong City, Jiangsu Province to: Nantong City, Jiangsu Province"}, L: {q: "", near: "Nantong City, Jiangsu Province"}, D: {saddr: "Nantong City, Jiangsu Province", daddr: "Nantong City, Jiangsu Province", mabc_saddr: "be0000020f", mabc_daddr: "be000005cb"}, geocode: "", G: {q: "From: Nantong City, Jiangsu Province to: Nantong City, Jiangsu Province"}, K: {q: "From: Nantong City, Jiangsu Province to: Nantong City, Jiangsu Province "}},
Query: {type: "D "},
Stickyflags: {hl: "zh_cn "},
Viewport: {center: {Lat: 37.649034, LNG: 106.435547}, span: {Lat: 23.730996999999999, LNG: 39.902343999999999}, maptype: ""},
Resolvedpoiid: True,
Modules: [""],
Overlays: {sxcar: false },
Panel: "The route is being calculated. Please wait ......",
Panelstyle: "",
Panelid: 0,
Printheader: "...",
Addressbook :{......},
Signed_in: True
}, "State ");
}

In this code, you can also use the mapabc code "mabc_saddr:" be0000020f "and mabc_daddr:" be000005cb "obtained from geocoding ""
. Next we will use another interface http://mapgoogle.mapabc.com/mapabc/mapabcrouting of mapabc? Param = be0000020f; be000005cb & url =
The two encodings in the Param parameter are clearly the starting and ending points we just obtained. Open the source code of this link and find routetext and polyline in Js.
These two variables are not pasted out after the code is too long. The values of these two variables are base64 encoded. Let's restore them. Routetext is the text description of a route, which is an XML
File format.

XML version = "1.0" encoding = "UTF-8 ″? & Gt;
& Lt; routingj OK = "T" & gt;
& Lt; count & gt; 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.