user3802409
user3802409

Reputation:

leaflet geocoding with input box

I'm coding a website which is using bootstrap. I have a leaflet map on it. I must use geocoding and reverse geocoding. I try this plugin but i have some problems.

1 - I want to use a searchbox which is not on the map.

I have an input box which is in the diffrent div from map's div. This plugin adds a map control to search adresses. How can i use my input box to search adresses? Maybe i must use only a provider not a plugin for geocoding. But how?

2 - Marker's latlng for reverse geocoding

I have a marker which is draggable. When i stop dragging the marker, I want to get adress from marker's latlng.

So, I want a geocoding provider which is free to do all of this. Or modify plugin for my purposes.

Upvotes: 3

Views: 4487

Answers (1)

Liedman
Liedman

Reputation: 10319

Yes, you should use the providers directly if you do not want to use the control's own input and other features. Each provider has a method called GetLocations, which takes two arguments:

  • qry: string containing the search query
  • callback: a function that will be called when the results are available from the provider. This function should take an array of results as its single argument

From the looks of it, each provider result will contain:

  • X: longitude
  • Y: latitude
  • Label: name

I haven't worked with this plugin myself, but it's very similar to how my own geocoding plugin, Leaflet Control Geocoder, works.

Leaflet Control Geocoder also has the functionality you request in your other question: each provider has a method called reverse, which takes a LatLng as argument instead of a string query. From a quick look, it appears GeoSearch doesn't have that functionality, but I might just have missed it.

Upvotes: 3

Related Questions