Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Marker not draggable after search #8

Open
kasoft opened this issue Jan 8, 2020 · 0 comments
Open

Marker not draggable after search #8

kasoft opened this issue Jan 8, 2020 · 0 comments

Comments

@kasoft
Copy link
Contributor

kasoft commented Jan 8, 2020

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.

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

No branches or pull requests

1 participant