|
@@ -21,6 +21,7 @@
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<div class="col-sm-4">
|
|
<div class="btn btn-primary" id="location-keyword-search">搜索</div>
|
|
<div class="btn btn-primary" id="location-keyword-search">搜索</div>
|
|
|
|
+ <div class="btn btn-success" id="my-location-btn">我的位置</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="row">
|
|
@@ -45,7 +46,7 @@ $(function() {
|
|
position: event.latLng,
|
|
position: event.latLng,
|
|
map:map
|
|
map:map
|
|
});
|
|
});
|
|
- console.log(event.latLng);
|
|
|
|
|
|
+ $('#select-position-input').val(event.latLng.lat + ',' + event.latLng.lng);
|
|
qq.maps.event.addListener(map, 'click', function(event) {
|
|
qq.maps.event.addListener(map, 'click', function(event) {
|
|
marker.setMap(null);
|
|
marker.setMap(null);
|
|
});
|
|
});
|
|
@@ -59,7 +60,37 @@ $(function() {
|
|
var regionText = $('#location-keyword-input').val();
|
|
var regionText = $('#location-keyword-input').val();
|
|
searchService.setLocation(regionText);
|
|
searchService.setLocation(regionText);
|
|
searchService.search();
|
|
searchService.search();
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $('#my-location-btn').on('click', function () {
|
|
|
|
+ if (navigator.geolocation) {
|
|
|
|
+ navigator.geolocation.getCurrentPosition(sgShowPosition);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ alert('浏览器不支持定位')
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ function sgShowPosition(position)
|
|
|
|
+ {
|
|
|
|
+ var lat = position.coords.latitude;
|
|
|
|
+ var lng = position.coords.longitude;
|
|
|
|
+ //调用地图命名空间中的转换接口 type的可选值为 1:GPS经纬度,2:搜狗经纬度,3:百度经纬度,4:mapbar经纬度,5:google经纬度,6:搜狗墨卡托
|
|
|
|
+ qq.maps.convertor.translate(new qq.maps.LatLng(lat, lng), 1, function(res){
|
|
|
|
+ //取出经纬度并且赋值
|
|
|
|
+ var latlng = res[0];
|
|
|
|
+ console.log(latlng);
|
|
|
|
+ var map = new qq.maps.Map(document.getElementById("container"), {
|
|
|
|
+ center: latlng,
|
|
|
|
+ zoom: 13
|
|
|
|
+ });
|
|
|
|
+ //设置marker标记
|
|
|
|
+ var marker = new qq.maps.Marker({
|
|
|
|
+ map : map,
|
|
|
|
+ position : latlng
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
@endsection
|
|
@endsection
|