More useless, first put two pictures to let us see the specific effect:
Figure 1, Baidu map search results
Figure 2, the effect of Arcgis for JavaScript implementation
See the effect, is not everyone a little chicken move, is not also spoil the move, there is wood? But how is it implemented? Let me give you a detailed talk about my idea of realization.
First, the data.
In fact, the object of the search from the type, should be points, lines, polygons are supported, but in the actual operation, whether Baidu or I do their own time, will be all the object of the point of the object, that is, to convert each object into a POI hotspot, and then the object's coordinate information extracted, all the objects into storage.
Second, realize.
To achieve this effect, first, based on the user's query criteria from the database to obtain data, the data returned to the Web is in JSON format. After getting to the data, then do the data on the left side of the page display and the map to the left of the list corresponding to the display, the left side of the list of the show I do not elaborate, have done the web there are 10,000 ways to achieve it, focusing on the display on the map.
These red bubbles are a graphiclayer, each bubble is a graphic, just according to different order, graphic Picturemarkersymbol is different, the following is the implementation of the Code:
<span style= "white-space:pre" ></span>addquerypopup = function (data) {redpopuplayer.clear (); var mlpoint = New Esri.geometry.Multipoint (New ESRI. Spatialreference ({wkid:4326})), var graphic = null;for (var i=0;i<data.length;i++) {var Att=data[i];var pt = new Esri.geometry.Point (Att.x,att.y,new Esri. Spatialreference ({wkid:4326})); Mlpoint.addpoint (PT); var sms = Null;switch (i) {Case 0:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/a.png", 15,19); Case 1:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/b.png", 15,19); Case 2:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/c.png", 15,19); Case 3:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/d.png", 15,19); Case 4:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/e.png", 15,19); Case 5:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/locatiOn_icon/f.png ", 15,19); Case 6:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/g.png", 15,19); Case 7:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/h.png", 15,19); Case 8:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/i.png", 15,19); default:{sms = new Esri.symbol.PictureMarkerSymbol ("Index/css/map/images/location_icon/j.png", 15,19);}} Graphic = new ESRI. Graphic (PT, SMS, ATT); Redpopuplayer.add (graphic);} var extent = Mlpoint.getextent (); Map.setextent (Extent.expand (2));};
In this way, a similar effect is achieved.
Thirdly, linkage.
Linkage, what is a concept? For the results of the search, click on the bubble, the object will pop up the information, as follows:
Figure 3, the information box of Baidu Map
Figure 4, Information box for ArcGIS
The so-called linkage, is to click on the left-hand list can also pop-up click on the red bubble like the message box, then how to implement in ArcGIS? Let's talk about my idea of how to achieve this effect.
Generally speaking, the content of the information box is mostly dynamically obtained, so my processing is to pass a unique encoding ID of the object parameters, in the background after obtaining data in the background to spell HTML code or to the foreground to spell HTML code, the implementation method is as follows:
<span style= "White-space:pre" ></span>/** * Display object information box Infowindow */showobjinfo = function (id) {$.ajax ({ URL: "wateruserbasecontroller.do?baseinfosummary&id=" +id, Type: "POST", dataType: "HTML", success : function (data) { data=eval (data), var pt = new Esri.geometry.Point (data.x,data.y,{wkid:4326}); var name = Data.name ; Map.infoWindow.resize (350,300); Map.infoWindow.setTitle (name+ "<a class= ' detailsinfo ' id= ' detailsinfo ' > details </a> "), $ (" #detailsinfo "). On (" click ", Function () {showobjdetailinfo (id,name);}); Map.infoWindow.setContent (data.html); Map.infoWindow.show (PT);} );};
With the above method, the same method is called when the left list and the marker object are clicked, passing the parameter as the unique encoding ID of the object.
Eye-thin friends may see, in the Information box title bar There is a detailed link, yes, this link is working, click the Detailed link, pop up the details of the object, the method is called as follows:
<span style= "White-space:pre" ></span>/** * Show Details */showobjdetailinfo = function (id) {<pre name= "code" class= "JavaScript" ><span style= "White-space:pre" ></span>$.ajax ({ URL: " Wateruserbasecontroller.do?baseinfo&id= "+id, Type:" POST ", dataType:" html ", success:function ( Data) { data=eval (data); var name = data.name;$. Window.settitle (name);
<span style= "White-space:pre" ></span>$. Window.setcontent (data.html); $. Window.show (); }});
};
The method is similar to displaying the information box, passing the unique encoding ID of an object to query the details of the object, composing HTML code in the background or foreground, displaying details such as:
Figure 5, more information
Well, Ok, the function has been realized, explain to this end!
The Arcgis for Javascript API is similar to how Baidu searches for a, B, C, D marker implementations