Can not pan map after select geosearch result
See original GitHub issueI use leaflet-geosearch 3.0.5. I do not use leaflet-geosearch own marker as I want to use my own draggable marker.
Before select search result, I can pan map or drag my own marker. When user select search result, I set my draggable marker position based on selected address location and map is centered to marker. It works fine.
The problem is after that I can not pan map when I drag outside marker. I can only drag marker. This is my code.
<script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
<script src="https://unpkg.com/leaflet-geosearch@3.0.5/dist/geosearch.umd.js"></script>
<script>
$(document).ready(function(){
var centerView = [{{ config('map.mapbox.center.latitude') }}, {{ config('map.mapbox.center.longitude') }}];
L.mapbox.accessToken = '{{ config('map.mapbox.key') }}';
var map = L.mapbox.map('map')
.setView(centerView, {{ config('map.mapbox.zoom') }})
.addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'))
.addControl(new L.Control.Fullscreen())
.addControl(
new GeoSearch.GeoSearchControl({
showMarker : false,
autoClose : true,
searchLabel : 'Search address',
notFoundMessage : 'Address is not found',
provider: new GeoSearch.OpenStreetMapProvider()
})
);
var marker = L.marker(centerView, {
draggable: true
}).addTo(map);
//handle geocoder event when location is found
map.on('geosearch/showlocation', function(e) {
var newLatLng = new L.LatLng(e.location.y, e.location.x);
marker.setLatLng(newLatLng);
$('#latitude').val(newLatLng.lat);
$('#longitude').val(newLatLng.lng);
});
var ondragend = function () {
var ll = marker.getLatLng();
$('#latitude').val(ll.lat);
$('#longitude').val(ll.lng);
};
// every time the marker is dragged, update the form
marker.on('dragend', ondragend);
// set the initial values in the form
ondragend();
});
</script>
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Getting coordinates after address has been picked in ...
I need to retrieve the result once the user has picked the correct address from the search bar, so I can make spatial...
Read more >smeijer/leaflet-geosearch: A geocoding/address-lookup ...
Default behaviour is to zoom and pan to the search result. With retainZoomLevel on true , the map is only panned. animateZoom controls...
Read more >L.GeoSearch
Before select search result, I can pan map or drag my own marker. When user select search result, I set my draggable marker...
Read more >Leaflet geosearch - binding results marker to an existing one
I took a quick peek into their source code and that property is only used to extract its values, it won't actually use...
Read more >geoSearch | InstantSearch.js
An InstantSearch.js widget for showing search results on a Google Map based on ... .ais-GeoSearch-map { height: 500px; /* You can change this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@smeijer I can confirm, upgrading to 3.3.2 fix issue.
Thanks for reporting back @zamronyp