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

i want to change marker position with onDrag property but when onDrag or onMove or onClick on map change marker position to very far place !! #16

Open
mojtabadarzi opened this issue Sep 16, 2020 · 3 comments

Comments

@mojtabadarzi
Copy link

mojtabadarzi commented Sep 16, 2020

first position
second position

const Map = Mapir.setToken({
  transformRequest: (url) => {
    return {
      url: url,
      headers: {
        "x-api-key":
          "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImE1YmQwZDQxMzg4NWVlMzQ1MDZlMTEwODdkNDg3MjFhZDlkMGNkZmVjODI5ZmY0MzMyYTQxNzFiM2E1ODU2YWEzMDM2OWY5NTIzYjI3NzhiIn0.eyJhdWQiOiIxMDg2OCIsImp0aSI6ImE1YmQwZDQxMzg4NWVlMzQ1MDZlMTEwODdkNDg3MjFhZDlkMGNkZmVjODI5ZmY0MzMyYTQxNzFiM2E1ODU2YWEzMDM2OWY5NTIzYjI3NzhiIiwiaWF0IjoxNjAwMjQyMzkxLCJuYmYiOjE2MDAyNDIzOTEsImV4cCI6MTYwMjkyNDM5MSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.ZHDdjrHPwsQ0eq0fwZgFfofHreeKMOozyW4HItdSjrni8JIv6z_R5nwWq0ecOThc2t6JklxhQs_5bBf0c95l5_jeOSqewMB9DRvO8gyCvySpnDRuib8ULDsYdGMAnOanmrw2Ynfc07zHlYHpgV9sL7ydp2ydNWBHZ4dNXSoHSiZZgn7aoY6tSoxCRH4JqOZGpJ0uKPtKu3ZurIy1q0dNiks2_c8YXrpjMtJsKbleQ7wK8he9u3n_jsYBTIawxhjjCKxegOw1_CJBY3yuamSRJad1vzPwCmoPDM9rzjRXHU6Z-bWkfuxuhHSMj41SxxjWz64nSVD8jaAHqsAqY1c2rQ",
        "Mapir-SDK": "reactjs",
      },
    };
  },
});
  const onDrag = (e) => {
    const lat = e?.transform?._center?.lat;
    const lng = e?.transform?._center?.lng;
    setLat(lat);
    setLng(lng);
  };
<Mapir
   Map={Map}
   userLocation
  onDrag={onDragEnd}
>
     <Mapir.Marker
       coordinates={[lat, lng]}
       anchor="top"
       Image={LocationGreen}
       className="fixed top-0 left-0 right-0 bottom-0 bg-glass1"
      >
                     
   </Mapir.Marker> 
</Mapir>
@soudabeeh
Copy link
Contributor

soudabeeh commented Sep 19, 2020

hi,
change lat,lng position to lng,lat .
<Mapir.Marker
coordinates={[lng,lat]}
anchor="top"
Image={LocationGreen}
className="fixed top-0 left-0 right-0 bottom-0 bg-glass1"
>

you can call us at this number
021-42070000

@mojtabadarzi
Copy link
Author

@soudabeeh
Copy link
Contributor

for draggable marker use this:
<Mapir
center={[51.420470, 35.729054]}
Map={Map}
>
<Mapir.Image id={"image-marker"} url={'markerURL'} />
<Mapir.Layer id="layer" layout={{ "icon-image": "image-marker", 'icon-allow-overlap': true }}>
<Mapir.Feature coordinates={[51.420470, 35.729054]} draggable={true} />
</Mapir.Layer>

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