Skip to content

add search by latitude/longitude #13

@ccloquet

Description

@ccloquet

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)
        }
    }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions