Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 + ")");
}

when I try currentLocation.zoom I get undefined.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
191 views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...