C # sogou map API application summary,

Source: Internet
Author: User
Tags polyline hasownproperty

C # sogou map API application summary,

Map Initialization
1. Add the reference map API file: <script src = "http://api.go2map.com/maps/js/api_v2.5.1.js" type = "text/javascript"> </script>
2. Website initialization loading event: window. onload = function () {var map = new sogou. maps. Map (document. getElementById ("map_canvas "),{});}
Create a div with the id of map_canvas and customize the div style. The map is automatically loaded when the website is running;

The Code is as follows:

<Html xmlns = "http://www.w3.org/1999/xhtml"> Show mocheng city map

Key code:

Window. onload = function () {var myOptions = {zoom: 10, center: new sogou. maps. point (12956000,482 4875)}; // city coordinate. The coordinate is Beijing coordinate var map = new sogou. maps. map (document. getElementById ("map_canvas"), myOptions );}View Code

Map attributes

Lists common attributes, such as map movement, map type conversion, and jump to a specified city.

The Code is as follows:

<Html xmlns =" http://www.w3.org/1999/xhtml "> <Head id =" Head1 "runat =" server "> <title> </title> <style type =" text/css "> html {height: auto ;} body {height: auto; margin: 0; padding: 0 ;}# map_canvas {width: 1000px; height: 500px; position: absolute ;}@ media print {# map_canvas {height: 950px ;}</style> <script src =" http://api.go2map.com/maps/js/api_v2.5.1.js "Type =" text/javascript "> </script> <script> var map; // create a global variable window. onload = function () {var myOptions = {zoom: 10, center: new sogou. maps. point (12956000,482 4875)}; // specify the city map = new sogou. maps. map (document. getElementById ("map_canvas"), myOptions); // create a map} // setMapTypeId method example function setMapTypeId (num) {// set the map type, for example: // sogou. maps. mapTypeId. ROADMAP common map // sogou. maps. mapTypeId. SATELLITE map // sogou. maps. mapTypeId. HYBRID map of HYBRID satellite and road network // map. setMapTypeId (sogou. maps. mapTypeId. HYBRID) switch (num) {case 1: map. setMapTypeId (sogou. maps. mapTypeId. ROADMAP); break; // normal map case 2: map. setMapTypeId (sogou. maps. mapTypeId. SATELLITE); break; // SATELLITE map case 3: map. setMapTypeId (sogou. maps. mapTypeId. HYBRID); break; // HYBRID map of satellite and road network} // example map of the panBy method manual movement function panBy (a, B) {map. panBy (a, B)} // The setOptions method example shows the specified region function setOptions () {// map center, level, and type map are set at the same time. setOptions ({center: new sogou. maps. point (13522000,364 1093), zoom: 12, mapTypeId: sogou. maps. mapTypeId. ROADMAP})} // The setCenter method example shows that the specified region a and B are map coordinates, and C is map-level function setCenter (a, B, c) {map. setCenter (new sogou. maps. point (a, B), c)} // The fitBounds method example jumps to the function fitBounds () {// sets the range var bounds = new sogou near the Palace Museum. maps. bounds (12955101,482 4738, 12958355,482 7449); // set the map to display the range in full. // note: the bounds value is not set, but the map is adjusted to the appropriate position. fitBounds (bounds )} </script> Map point attributes

A map is a very important attribute. Adding a chart to a map is a common method attribute,

Sogou API provides two types of tracking, default tracking and dynamic addition of tracking

Add by default:

Var location = new sogou. maps. point (12956000,482 4875); // specify the position var map = new sogou. maps. map (document. getElementById ("map_canvas"), {}); // initialize map var marker = new sogou. maps. marker ({position: location, // stroke coordinate title: "stroke", // stroke name label: {visible: true, align: "BOTTOM "}, // map: map,}); // Add a mapView Code

Add dynamic points

Window. onload = function () {// initialize map = new sogou. maps. map (document. getElementById ("map_canvas"), {}); // Add a click event sogou for the map. maps. event. addListener (map, 'click', function (event) {var marker1 = new sogou. maps. marker ({position: event. point, map: map });});}View Code

Ranging Based on two strokes

// Obtain the unique function getInstance (a) {. hasOwnProperty ("_ instance") | (. _ instance = new a); return. _ instance} // function Lines (myLatlng, myPoint) {var convertor = getInstance (sogou. maps. convertor); var distance = convertor. distance (myLatlng, myPoint); // two-point link var line = new sogou. maps. polyline ({path: [myLatlng, myPoint], strokeColor: "# FF0000", strokeOpacity: 1.0, strokeWeight: 1, title: parseInt (distance) + "meter", map: map });}View Code

A small module is created based on the above attributes. The dynamic ranging code on the map is as follows:

<Html xmlns =" http://www.w3.org/1999/xhtml "> <Head id =" Head1 "runat =" server "> <title> </title> <style type =" text/css "> html {height: auto ;} body {height: auto; margin: 0; padding: 0 ;}# map_canvas {width: 1000px; height: 500px; position: absolute ;}@ media print {# map_canvas {height: 950px ;}</style> <script src =" http://api.go2map.com/maps/js/api_v2.5.1.js "Type =" text/javascript "> </script> <script> var map; var num; var Listener; // obtain the unique function getInstance (a) {. hasOwnProperty ("_ instance") | (. _ instance = new a); return. _ instance} window. onload = function () {// initialize map = new sogou. maps. map (document. getElementById ("map_canvas"), {});} function AddCj () {var mypointh; var myPoint; num = 0; // Add a click event for the map, display the current coordinates after clicking, and add a click Ener ing Listener = sogou. maps. event. addListener (map, 'click', function (event) {if (num = 0) {mypointh = myPoint = event. point; // obtain the coordinates of the click position} else {myPoint = mypointh; mypointh = event. point; // obtain the coordinates of the click position} Lines (mypointh, myPoint); num ++;});} function DelCj () {sogou. maps. event. removeListener (Listener)} // two-point connected function Lines (myLatlng, myPoint) {var convertor = getInstance (sogou. maps. convertor); var distance = convertor. distance (myLatlng, myPoint); // two-point link var line = new sogou. maps. polyline ({path: [myLatlng, myPoint], strokeColor: "# FF0000", strokeOpacity: 1.0, strokeWeight: 1, title: parseInt (distance) + "meter", map: map}); placeMarker (myLatlng, parseInt (distance);} // dynamically Add a lookup point and create a lookup function placeMarker (location, jl) based on the specified coordinates) {var clickedLocation = location; var marker1 = new sogou. maps. marker ({position: location, title: jl + "meters", label: {visible: true, align: "BOTTOM"}, map: map});} function Mapclear () {num = 0; map. clearAll ();} </script>  


Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

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.