C # sogou map API application Summary (2 ),

Source: Internet
Author: User

C # sogou map API application Summary (2 ),

Add the functional modules you want on the map

The Code is as follows:

1 var map; 2 window. onload = function () {3 var myOptions = {4 mapControl: false, // disable the default control 5 mapTypeId: sogou. maps. mapTypeId. ROADMAP 6} 7 map = new sogou. maps. map (document. getElementById ("map_canvas"), myOptions); // initialize map 8 9 10 var homeControlDiv = document. createElement ('div '); // create 11 homeControlDiv. style. position = "absolute"; 12 homeControlDiv. style. left = "20px"; 13 homeControlDiv. style. top = "5px"; 14 15 var homeControl = new HomeControl (homeControlDiv, map); // obtain control 16 map. getContainer (). appendChild (homeControlDiv); // Add the control to map 17 18 19} 20 function HomeControl (controlDiv, map) {21 22 controlDiv. style. padding = '5px '; 23 24 // ranging function 25 var goHomeText = document. createElement ('div '); 26 goHomeText. style. fontFamily = 'arial, sans-serif'; 27 goHomeText. style. backgroundColor = 'white'; 28 goHomeText. style. cursor = 'pointer '; 29 goHomeText. style. borderStyle = 'solid'; 30 goHomeText. style. borderWidth = '1px '; 31 goHomeText. style. borderColor = 'black'; 32 goHomeText. style. fontSize = '12px '; 33 goHomeText. style. textAlign = 'center'; 34 goHomeText. style. float = 'left'; 35 goHomeText. style. width = "60px"; 36 goHomeText. innerHTML = '<B> ranging </B>'; 37 controlDiv. appendChild (goHomeText); 38 39 // get coordinates 40 var SetZbText = document. createElement ('div '); 41 SetZbText. style. fontFamily = 'arial, sans-serif'; 42 SetZbText. style. backgroundColor = 'white'; 43 SetZbText. style. cursor = 'pointer '; 44 SetZbText. style. borderStyle = 'solid'; 45 SetZbText. style. borderWidth = '1px '; 46 SetZbText. style. borderColor = 'black'; 47 SetZbText. style. fontSize = '12px '; 48 SetZbText. style. textAlign = 'center'; 49 SetZbText. style. float = 'left'; 50 SetZbText. style. width = "60px"; 51 SetZbText. innerHTML = '<B> get coordinates </B>'; 52 controlDiv. appendChild (SetZbText); 53 54 // clear excess lookup 55 var setHomeText = document. createElement ('div '); 56 setHomeText. style. fontFamily = 'arial, sans-serif'; 57 setHomeText. style. backgroundColor = 'white'; 58 setHomeText. style. cursor = 'pointer '; 59 setHomeText. style. borderStyle = 'solid'; 60 setHomeText. style. borderWidth = '1px '; 61 setHomeText. style. borderColor = 'black'; 62 setHomeText. style. fontSize = '12px '; 63 setHomeText. style. textAlign = 'center'; 64 setHomeText. style. float = 'left'; 65 setHomeText. style. width = "60px"; 66 setHomeText. innerHTML = '<B> clear </B>'; 67 controlDiv. appendChild (setHomeText); 68 69}View Code

Code effect:

Dynamically add plotting points to a map (which can be managed in the background)

1 var map; 2 var MapZBs, Listener; 3 var num; 4 // obtain the unique example of the Class 5 function getInstance (a) {6. hasOwnProperty ("_ instance") | (. _ instance = new a); 7 return. _ instance 8} 9 window. onload = function () {10 var myOptions = {11 mapControl: false, // disable the default control 12 mapTypeId: sogou. maps. mapTypeId. ROADMAP13} 14 map = new sogou. maps. map (document. getElementById ("map_canvas"), myOptions); // initialize map 15 16 17 Marks (); // Dynamically Add a profile 18} 19 // dynamically Add a profile 20 function Marks () {21 // ajax Dynamically Retrieve background data 22 var marks; 23 $. ajax ({24 type: "post", 25 contentType: "application/json", 26 url: "Index. aspx/GetMarks ", 27 success: function (data) {28 FxData (data. d); 29} 30}) 31} 32 // graph Content Analysis 33 function FxData (Data) {34 var array = Data. split ('|'); 35 var HtmlCon = ""; 36 for (var j = 0; j <array. length; j ++) {37 if (array [j]. toString ()! = "") {38 var Yarr = array [j]. split ('&'); 39 var TypeImages; 40 switch (Yarr [4]. toString () {41 case "1": TypeImages = "images/b1.png"; break; 42 case "2": TypeImages = "images/o1.png"; break; 43 case "3": TypeImages = "images/r1.png"; break; 44 case "4": TypeImages = "images/z1.png"; break; 45} 46 HtmlCon + = '<li id = "mark' + (j + 1) + '"class =" ">

The ajax background code is

1 [WebMethod] 2 public static string GetMarks () 3 {4 string str = ""; 5 DataTable dt = GetData (); 6 foreach (DataRow rows in dt. rows) 7 {8 str + = rows ["PointX"]. toString () + "&" + rows ["PointY"]. toString () + "&" + rows ["Company"]. toString () + "&" + rows ["Explain"]. toString (); 9 str + = "&" + rows ["MarkType"]. toString () + "&" + rows ["ComImage"]. toString () + "|"; 10} 11 return str; 12} 13 14 private static DataTable GetData () 15 {16 DataTable dt = new DataTable (); 17 string SQL = "select * from MapMark"; 18 SqlConnection cnn = new SqlConnection (SqlCon); 19 using (SqlCommand cmm = new SqlCommand (SQL, cnn )) 20 {21 using (SqlDataAdapter dapter = new SqlDataAdapter (cmm) 22 {23 dapter. fill (dt); 24} 25} 26 return dt; 27}View Code

Code effects:


C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.