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

add search by latitude/longitude #13

Open
ccloquet opened this issue Sep 8, 2016 · 2 comments
Open

add search by latitude/longitude #13

ccloquet opened this issue Sep 8, 2016 · 2 comments

Comments

@ccloquet
Copy link

ccloquet commented Sep 8, 2016

Is this functionality useful for others ?

I added the possibility to search by latitude & longitude in handleResults (quick & dirty). Then, you can type a lat/lon pair in the search box. When a valid pair is detected, it appears on top of the list, so that the user can select it easily.

handleResults: function(geojson) 
{
    var v   = $('.photon-input').val(); 
    var w = v.split(','); 

    if (w.length == 2) 
    {
        var lat = parseFloat(w[0])
        var lon = parseFloat(w[1])

        if ((lat >= -90) & (lat <= 90) & (lon >= -180) & (lon <= 180))
        {
            // later : geocode the adress
            var p = {"geometry":{"coordinates":[lon,lat],"type":"Point"},
            "type":"Feature","properties":
            {"osm_id":-1,"osm_type":"W","extent":[0,0,0,0],"country":"","osm_key":"","city":"","osm_value":"latitude/longitude","postcode":"","name": lat  + ',' + lon,"state":""}}

            geojson.features.unshift(p)
        }
    }
...
@jengalas
Copy link

It's very useful for me. Thank you for your contribution!

@b3hr4d
Copy link

b3hr4d commented Jan 18, 2020

thanks for the tip its useful .

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

3 participants