The High German map coordinates query tool -- JavaScript

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The recent need to query the coordinate High German map somewhere, but suffer from High German map did not provide this function. Fortunately, the High German map provided by JavaScript API, he intended to write a query to coordinate their own tools, to share with everyone here.

The following code:

<!DOCTYPE html>

    <title>The High German map</title>
    <meta charset = "UTF-8" />
    <script src=" ;key=662b7a5d373bccb29453167d08245aef" type="text/javascript"></script>
        var mapObj;
        function getCoordinate(location){
            var geocoderOption = {
                crossnum:2,//Road intersection number
                roadnum:3,//Route record number
                poinum:2//The number of POI
            var geocoder = new AMap.Geocoder(geocoderOption);
            geocoder.geocode(location, function(data){
                var x = (data.list)[0].x;
                var y = (data.list)[0].y;
                document.getElementById("result").innerHTML = x + "," + y;

                var position=new AMap.LngLat(x,y);//To create the center coordinates
                if (!mapObj) {
                    mapObj=new AMap.Map("container",{center:position, level:18});//Create map examples
                }else {
    <style type="text/css">
        <input type="text" id="input1">
        <button type="button" onclick="getCoordinate(document.getElementById('input1').value)">Query coordinate</button>
    <div id="result"></div>
    <div id="container"></div>

When used directly the above code is copied to a text file, save as html type, use the browser to open, can be used directly.

The interface is as follows:

If you think might be helpful to you, also hope to help, thank you: )
Personal blog:
This paper addresses:
Reprint please indicate the source, thank you!
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Betty at December 04, 2013 - 3:27 AM