Нужно разобраться с вызовом WebServices Например: Есть Google maps
Код | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Google Maps</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> </head>
<script type="text/javascript"> var map; var line; var count = 0; var a = new Array(); // нужно вызвать WebMethod HelloWorld() , чтобы он вернул значения в переменную a function initialize() { var myLatlng = new google.maps.LatLng(51.533246, 46.034303); var myOptions = { zoom: 14, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
line = new google.maps.Polyline({ strokeColor: '#000000', strokeOpacity: 1.0, strokeWeight: 3 });
line.setMap(map); google.maps.event.addListener(map, 'tilesloaded', addLatLng); }
function addLatLng(e) { var path = line.getPath(); for (var i = 0; i < 6; i = i + 2) { var latLng = new google.maps.LatLng(a[i], a[i + 1]); path.push(latLng); } path.push(e.latLng); } </script>
<body style="margin:0px; padding:0px;" onload="initialize()"> <form id="form1" runat="server"> <div id="map_canvas" style="width:100%; height:100%"></div> </form> </body> </html>
|
и есть WebServices, в котором хранятся координаты
Код | using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq;
namespace WebApplication1 { /// <summary> /// Сводное описание для Dijkstra /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] // Чтобы разрешить вызывать веб-службу из сценария с помощью ASP.NET AJAX, раскомментируйте следующую строку. [System.Web.Script.Services.ScriptService] public class Dijkstra : System.Web.Services.WebService {
[WebMethod] public float[] HelloWorld() { double[] a = new double[6]; a[0] = 51.533246; a[1] = 46.037303; a[2] = 51.543100; a[3] = 46.044503; a[4] = 51.553546; a[5] = 46.054303; return a; } } }
|
Как в коде с картой вызвать ВебМетод? Подскажите что нужно и куда добавить, или ткните носом в пример в котором все понятно...
|