标题:新手问个geocode的问题
取消只看楼主
juhuayiqiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-6-10
结帖率:0
已结贴  问题点数:20 回复次数:0 
新手问个geocode的问题
我想将下面代码中获取的经纬度信息转换成具体的地址信息显示在地图下面空白处,对于geocode这个函数不太懂,哪位大神教教或者将那段代码插入我的代码中
程序代码:
<!DOCTYPE html>
<html>
    <head>
        <title>Device Properties Example</title>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <script type="text/javascript" src="http://maps. type="text/javascript" charset="utf-8">
        var lat;
        var lng;
        var watchID = null;
        function onDeviceReady() 
        {
            var options = { frequency: 10000 };
            watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
        }
        function onSuccess(position) 
        {
            lat = position.coords.latitude;
            lng = position.coords.longitude;
            var element = document.getElementById('geolocation');
            element.innerHTML = 'Latitude: ' + lat + '<br />' + 
                                'Longitude: ' + lng + '<br />' + 
                                '<hr />' + element.innerHTML;
            initialize();
        }
        function clearWatch() 
        {
            if (watchID != null) 
            {
                navigator.geolocation.clearWatch(watchID);
                watchID = null;
            }
        }
        function onError(error) 
        {
            alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
        }
        function initialize() 
        {
            var myLatlng = new google.maps.LatLng(lat,lng);
            var myOptions = {
                            zoom: 14,
                            center: myLatlng,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

            var marker = new google.maps.Marker({position:myLatlng,map:map,title:"CurrentPosition"
                        });
        }
        </script>
    </head>
    <body onload = "onDeviceReady();">
        <div id="map_canvas" style="height:400px;"></div>
        <br><div id="geolocation">Watching geolocation...</div></br>
        <button onclick="clearWatch();">Clear Watch</button>
    </body>
</html>
搜索更多相关主题的帖子: content title javascript 经纬度 
2012-06-10 14:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-371229-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045943 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved