腾讯地图定位

腾讯地图定位

<div class="c">
@Html.TextBoxFor(u => u.Address, new { @class = "text01", onchange = "changeAddress()", style = "margin:10px 0;" })
经度
@Html.TextBoxFor(u => u.Longitude, new { @class = "text05" })
纬度
@Html.TextBoxFor(u => u.Latitude, new { @class = "text05" })
<br />
区域
<input type="text" name="name" value="" placeholder="椒江" >
</div>
</div>
<!--腾讯地图-->
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&libraries=convertor"
    type="text/javascript"></script>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp" type="text/javascript"></script>
<script type="text/javascript">
    var searchService = null;
    function txmapinit() {
        var map = new qq.maps.Map(document.getElementById("txmap"), {
            center: new qq.maps.LatLng(39.916527, 116.397128),
            zoom: 13
        });
        //添加监听事件  获取鼠标点击事件
        qq.maps.event.addListener(map, 'click', function (event) {
            var lat = event.latLng.getLat();
            var lng = event.latLng.getLng();
            alert(lat)//纬度
            alert(lng)//经度
            var p = new qq.maps.LatLng(lat,lng);
            map.setCenter(p);
            $("input[name=Longitude]").val(lng);
            $("input[name=Latitude]").val(lat);
        });
        searchService = new qq.maps.SearchService({
            panel: document.getElementById('map_result'),
            map:map
        });
        getResult();
    }
    function getResult() {
        var poiText = document.getElementById("poiText").value;
        var regionText = document.getElementById("regionText").value;
        searchService.setLocation(regionText);
        searchService.search(poiText);
    }
    txmapinit();
</script>