Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map closes when zoom button clicked. #15

Open
hilaryb opened this issue May 13, 2021 · 2 comments
Open

Map closes when zoom button clicked. #15

hilaryb opened this issue May 13, 2021 · 2 comments

Comments

@hilaryb
Copy link

hilaryb commented May 13, 2021

Hello,
When you click the map zoom button, the map closes without you being able to select a position.
Tested on Chrome and IE 11

@hilaryb
Copy link
Author

hilaryb commented May 13, 2021

Also, if you click and drag the map, the map closes.

@dbeniamine
Copy link

I found a workaround : as I split the lontitude and latitude in two fields I do not use an input to store the geouri, so I had to launch manually the map.

If the map is opened manually it will not be closed by such events.

There is a snippet that add a span on which a click opens the map.

<script src=" https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.js "></script>
<link href=" https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.css " rel="stylesheet">
<script src=" https://cdn.jsdelivr.net/npm/leaflet-locationpicker@0.3.4/src/leaflet-locationpicker.min.js "></script>
<link href=" https://cdn.jsdelivr.net/npm/leaflet-locationpicker@0.3.4/src/leaflet-locationpicker.min.css " rel="stylesheet">
<span class="fas fa-map-marker-alt" type='disabled' id="geouri"></span>
<script type="text/javascript">
$().ready(function() {
       // retrieve coordinates from split input
	let coord = $('input[name=poslatitude]').val() + ',' + $('input[name=poslongitude]').val();
	$('#geouri').leafletLocationPicker({
		location: coord,
		onChangeLocation: function(o) {
                        // split location
			$('input[name=poslatitude]').val(o.latlng.lat);
			$('input[name=poslongitude]').val(o.latlng.lng);
                        // do not forget to close the map
			$('#geouri')[0].closeMap();
		}
	});
       // open map on close
	$('#geouri').on('click', function(e) {
		e.target.openMap()
	});
});
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants