This repository was archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Marker not draggable after search #8
Copy link
Copy link
Open
Description
In the example you can drag the Marker to a different Position. This is not possible after searching a Position. Here are some more Details:
Use Nomainatin as Service
// lets use nominating service
$nominatim = new ServiceNominatim();
// create geocoder plugin and attach the service
$geoCoderPlugin = new GeoCoder([
'service' => $nominatim,
'clientOptions' => [
// we could leave it to allocate a marker automatically
// but I want to have some fun
'showMarker' => true,
'collapsed' => false,
],
]);
Add Maker like in the example
$marker = new Marker([
'name' => 'geoMarker',
'latLng' => $center,
'clientOptions' => ['draggable' => true], // draggable marker
'clientEvents' => [
'dragend' => 'function(e){
console.log(e.target._latlng.lat, e.target._latlng.lng);
}'
]
]);
Now here is the callback, after the Marker is "moved"
// initialize our leafLet component
$leafLet = new LeafLet([
'name' => 'geoMap',
'tileLayer' => $tileLayer,
'center' => $center,
'zoom' => $zoom,
'clientEvents' => [
// I added an event to ease the collection of new position
'geocoder_showresult' => 'function(e){
// set markers position
geoMarker.setLatLng(e.Result.center);
geoMarker.dragging.enable(); // NOT WORKING !!!
$(\'input[name="lat"]\').val(e.Result.center.lat);
$(\'input[name="lng"]\').val(e.Result.center.lng);
}'
]
]);
I checked also the Vars geoMarker where draggable is set to true. But still, the Marker cannot be moved after performing a search.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels