android - Leafletjs map bounds changing with zoomlevel? -


i defined bounds map. on zoom level 15 geoposition displayed inside bounds inside viewport of android. keep geoposition , zoom level 17 , try locate position again. error message: position outside map (bounds). position not outside bounds outside viewport.

    // bounds     var bounds = new l.latlngbounds(         //south west         [48.121831504767464, 11.584824599741356],         //north east         [48.132744242329231, 11.612690096879318]     );      var map = l.map('map', {         maxzoom: 18,         minzoom: 15,         // -------------------- problem -------------------------         maxbounds: [             //south west             [48.121831504767464, 11.584824599741356],             //north east             [48.127287873548347, 11.612690096879318]         ]     }) .setview([48.127287873548347, 11.598757348310336], 15);      l.tilelayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {         attribution: '&copy; <a href="http://osm.org/copyright">openstreetmap</a> contributors'     }).addto(map);      // add control     var mycontrol = l.control.extend({         options: {             position: 'topleft'         },         onadd: function (map) {             var container = l.domutil.create('div', 'leaflet-bar leaflet-control');             // add anchor element             $(container).append(                 $("<a title='zeigt ihren standort an'>").addclass("locate-button")             );             return container;         }     });     map.addcontrol(new mycontrol());     

and

        // show position-marker costum icon         var positionmarker;         var positionicon = l.icon({             iconurl: '../leaflet/images/position-icon.png',             iconretinaurl: '../leaflet/images/position-icon-2x.png',             iconsize: [48, 48], // size of icon             iconanchor: [24, 24],             shadowsize: [1, 1], // size of shadow - here no shadow             popupanchor: [0, 0] // point popup should open relative iconanchor         });          // onclick position button (toggle)         var state = -1;         $('.locate-button').on('click', function(){             state=-state; // toggle state             if( state === 1 ){                 $('.locate-button').addclass('requesting');                 map.locate({setview: false, maxzoom: 18});             } else {                 map.removelayer(positionmarker);             }         });          // on found         map.on('locationfound', function onlocationfound(e){              // künstliche verzögerung um 2s zu testzwecken!!!               //window.settimeout( function(){                 $('.locate-button').removeclass('requesting');             //}, 2000 );               // -------------------- problem -------------------------             // detect if location outside map             if( !map.getbounds().contains(e.latlng)){                 alert("sie befinden sich außerhalb der verfügbaren karte, ihr standort wird daher nicht angezeigt.");                 return;             }              // set position             map.setview(e.latlng);              // var radius = e.accuracy / 2;             positionmarker = l.marker(e.latlng, {icon: positionicon}).addto(map)                 // .bindpopup("sie sind innerhalb eines radius von " + radius + " metern um diesen punkt herum").openpopup();             // l.circle(e.latlng, radius).addto(map);         }); 

where bug?

wolf


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -