本文介绍了jQuery Location Picker Plugin放大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jQuery Location Picker插件中获取zoom属性?我可以使用currentLocation.latitudecurrentLocation.longitude获取地图坐标,但是没有人知道如何获取zoom属性吗?

How can I get zoom property in jQuery Location Picker Plugin? I can get map coordinates using currentLocation.latitude and currentLocation.longitude, but does any body know how to get zoom property?

$('#the-map').locationpicker({
location: {latitude: 46.15242437752303, longitude: 2.7470703125},
radius: 300,
onchanged: function(currentLocation, radius, isMarkerDropped) {
    alert("Location changed. New location (" + currentLocation.latitude + ", " + currentLocation.longitude + ")");
}

当我尝试currentLocation.zoom时,我不确定.

when I try currentLocation.zoom I get undefined.

推荐答案

由于该插件不支持该地图事件,因此您必须自己绑定它...

since the plugin does not support that map-event, you'd have to bind it by yourself ...

google.maps.event.addDomListener(window, 'load', function() {

  $('#map_canvas').locationpicker({
      location: {latitude: 40.7324319, longitude: -73.82480777777776},
      radius: 300
  });

  /* bind the zoom_changed event for the plugin's map handle */
  $('#map_canvas').data('locationpicker').map.addListener('zoom_changed', function() {
    var map = $('#map_canvas').data('locationpicker').map;
    console.log('zoom level: ' + map.getZoom());
  });

});
html, body, #map_canvas {height: 100%; width: 100%; margin: 0px; padding: 0px;}
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maps.googleapis.com/maps/api/js"></script>
<script src="//rawgit.com/Logicify/jquery-locationpicker-plugin/master/dist/locationpicker.jquery.js"></script>
<div id="map_canvas"></div>

这篇关于jQuery Location Picker Plugin放大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 17:18