2amigos / yii2-leaflet-extension

Yii 2 Extension library to display interactive maps with Leaflet .
http://yiiwheels.com
Other
30 stars 26 forks source link

Ask for current location #42

Open neoacevedo opened 6 years ago

neoacevedo commented 6 years ago

I'ts a simple question: how do I to ask to user for its current location?

cebe commented 5 years ago

There is a plugin for leaflet: https://github.com/domoritz/leaflet-locatecontrol

neoacevedo commented 5 years ago

But, how to ask for it from here?:

$leaflet = new \dosamigos\leaflet\LeafLet([
    'center' => $center, // set the center
]);
tonydspaniard commented 5 years ago

@neoacevedo I would simply use any IP to LatLng service (for example: https://iplocation.com/) . It also depends on what you want to accomplish on your project. The mentioned plugin by @cebe also works if you wish to provide the solution on the frontend using scripts.

neoacevedo commented 5 years ago

@tonydspaniard I have used that plugin in standalone LeafLet maps where I can get the current location on page load, but my question is focused to the PHP environment, but I think I'm misunderstanding something in the process that I will check and post here later. Anyway I think, as suggestion, this should allow instantiate LeafLet without any parameter, an equivalent in JS:

var map = L.map('myDiv');