4

I'm trying to customize the GeoExt.form.field.GeocoderComboBox to use Here maps geocoder.

I can get the label field to display in the combo box and also convert the position into the format I need however I am unable to actually select the value in the combobox. It looks like the 'select' event is not firing and I have no idea why.

It looks like this does fire when I go with the default queryParam "q" although obviously it won't return what I actually want. So it would seem that me changing the queryParam to the one required by Here maps for some reason is stopping me selecting the address I put in.

Here's my code:

Ext.define('HQMap.view.tools.HereGeoCode', {
extend: 'GeoExt.form.field.GeocoderComboBox',
requires: [
    "Ext.data.proxy.JsonP",
    "Ext.data.JsonStore"
],
initComponent: function() {
    var me = this;
    var hereUrl = "http://geocoder.api.here.com/6.2/search.json?app_id=&app_code=&gen5&country=GBR";
    var hereStore = Ext.create("Ext.data.JsonStore", {
        root: null,
        fields: [
            {name: "bounds", convert: function(v, rec) {
                var bbox = rec.raw.Response.View[0].Result[0].Location.MapView;
                    return [bbox.TopLeft.Latitude, bbox.BottomRight.Longitude, bbox.BottomRight.Latitude, bbox.TopLeft.Longitude];
                    }
            },
            {name: "lonlat", convert: function(v, rec) {
                return [rec.raw.Response.View[0].Result[0].Location.DisplayPosition.Longitude, rec.raw.Response.View[0].Result[0].Location.DisplayPosition.Latitude];
                }
            },
            {name: "name", mapping: "Response.View[0].Result[0].Location.Address.Label"}
        ],
        proxy: Ext.create ("Ext.data.proxy.JsonP", {
            url: hereUrl,
            callbackKey: "jsoncallback"
            })
    });

    Ext.apply(me, {
        srs: "EPSG:900913",
        emptyText: "Search Address",
        url: hereUrl,
        locationField: "lonlat",
        displayField: "name",
        valueField: "bounds",
        queryParam: "searchtext",
        forceSelection: true,
        store: hereStore
    });

    me.callParent(arguments);
}

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.