I have a Heron/Geoext/ExtJS map. I found a site with this function and I would like to implement it.

So how can I use this function without their MapCentia.gc2 function? How can I rewrite it to use in my map?

            type: "any",
            options: {
                text: '',
                tooltip: 'Search with Google Places',
                iconCls: 'icon-map-magnify',
                id: "googleSearch",
                handler: function (objRef) {
                    if (!searchWin) {
                        searchWin = new Ext.Window({
                            title: "Find",
                            layout: 'fit',
                            width: 300,
                            height: 70,
                            plain: true,
                            closeAction: 'hide',
                            html: '<div style="padding: 5px" id="searchContent"><input style="width: 270px" type="text" id="gAddress" name="gAddress" value="" /></div>',
                            x: 300,
                            y: 70
                    if (typeof(objRef) === "object") {
                    } else {
                    }//end if object reference was passed
                    var input = document.getElementById('gAddress');
                    var options = {
                        //bounds: defaultBounds
                        //types: ['establishment']
                    var autocomplete = new google.maps.places.Autocomplete(input, options);
                    google.maps.event.addListener(autocomplete, 'place_changed', function () {
                        var place = autocomplete.getPlace();
                        var transformPoint = function (lat, lon, s, d) {
                            var p = [];
                            if (typeof Proj4js === "object") {
                                var source = new Proj4js.Proj(s);    //source coordinates will be in Longitude/Latitude
                                var dest = new Proj4js.Proj(d);
                                p = new Proj4js.Point(lat, lon);
                                Proj4js.transform(source, dest, p);
                            else {
                                p.x = null;
                                p.y = null;
                            return p;
                        var p = transformPoint(place.geometry.location.lng(), place.geometry.location.lat(), "EPSG:4326", "EPSG:900913");
                        var point = new OpenLayers.LonLat(p.x, p.y);
                        MapCentia.gc2.map.setCenter(point, 17);
                        try {
                        } catch (e) {

                        try {
                        } catch (e) {
// which heron/geoext/extjs is equivalent of these?
                        placeMarkers = new OpenLayers.Layer.Markers("Markers");
                        placeMarkers.addMarker(new OpenLayers.Marker(point));
                        placePopup = new OpenLayers.Popup.FramedCloud("place", point, null, "<div id='placeResult' style='z-index:1000;width:200px;height:50px;overflow:auto'>" + place.formatted_address + "</div>", null, true, function(){


MapCentia.gc2.map is referencing the OpenLayers map object. So just switch it out with Heron.App.map.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.