Search tool in MapXtreme

161 views
Skip to first unread message

dka

unread,
Jul 28, 2012, 2:34:05 AM7/28/12
to mapi...@googlegroups.com
Hi Group,

Is there any Out of the Box search tool available in MapXtreme, which can be used in MapXtreme web application. We are trying to provide search functionality to the Web Application. Any help would be highly appreciated.

Regards,
Deepak

Mustafa ÖZÇETiN

unread,
Jul 30, 2012, 4:30:58 AM7/30/12
to mapi...@googlegroups.com
You must implement your own find tool. There is a sample app. in MapXtreme documentation named "Find". To start, you may examine this sample.

Also I can give some code snippets in C# that may be helpful. Assume that we want to write a "find street" tool in a MX web app. For that, we must write:

1) Client side (e.g. JavaScript/AJAX) code to send a parameter
(e.g. street id to find) to the server
2) A FindStreet command deriving from MapBaseCommand
3) A method that will perform the actual find process, namely findStreet() below

In my implementations, I always use unique object IDs for all objects in my layers. When I, for instance, want to find a street, I get its id from the client side with JavaScript and send it to the server via a get or AJAX request. Such a request address can be

var url = "HttpHandlers/HndStreetQuery.ashx?streetId="+streetId;

in the JavaScript code, which must be sent to an Http Handler, namely HndStreetQuery.ashx

In the server side, your find command may be like:

[Serializable]
public class FindStreet : MapBaseCommand {
    public FindStreet() {
        Name = "FindStreet";
    }

    public override void Process() {
        string streetId = HttpContext.Current.Request.QueryString["streetId"];
        MapUtils.findStreet(Convert.ToInt32(streetId));
        MapControlModel model = MapControlModel.GetModelFromSession();
        MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
        StreamImageToClient(ms);
    }
}

The streetId variable here is the one coming from the client streetId parameter.

With regard to the find method, it may be something like:

public static void findStreet(int id) {
    Map map = Session.Current.MapFactory[0];
    FeatureLayer findLayer = (FeatureLayer)map.Layers["STREET_LAYER"];
    Find find = new Find(findLayer.Table, findLayer.Table.TableInfo.Columns["ID"]);
    FindResult result = find.Search(id.ToString());
    if (result.ExactMatch) {
        map.Center = new DPoint(result.FoundPoint.X, result.FoundPoint.Y);
        Distance d = new Distance(0.15, map.Zoom.Unit);
        map.Zoom = d;
    }
}

Finally, I strongly recommend you to read the chapter "Web Applications, Controls, and Tools" in the MapXtreme
Developer Guide document. This chapter explains the request/response cyle step by step.

Regards,

Mustafa ÖZÇETiN

Senior Researcher

The Scientific and Technological Council of Turkiye
Ankara / Turkiye




From: dka <deepa...@gmail.com>
To: mapi...@googlegroups.com
Sent: Saturday, July 28, 2012 9:34 AM
Subject: [MI-L] Search tool in MapXtreme

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en


Reply all
Reply to author
Forward
0 new messages