【问题标题】:C#: Creation of a Google Map with a line?C#:用一条线创建谷歌地图?
【发布时间】:2010-11-19 07:17:56
【问题描述】:

经过三天的尝试,我几乎要放弃了.. 我尝试使用 Google Maps API 创建由多个点组成的较长线的地图。不幸的是,我什至无法上传 XML 文件(尽管我成功地使用我的 Google 帐户授权了自己)。

有人可以帮助我并发布有关如何创建地图并在其上画线的 C#/VB 代码 (sn-p) 吗?感谢您的帮助!

诺伯特

【问题讨论】:

    标签: c# google-maps google-maps-api-3


    【解决方案1】:

    如果您对 Google 地图使用 javascript API,这里有一个示例:

    <!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps JavaScript API v3 Example: Polyline Simple</title>
    <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    
      function initialize() {
        var myLatLng = new google.maps.LatLng(0, -180);
        var myOptions = {
          zoom: 3,
          center: myLatLng,
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };
    
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
        var flightPlanCoordinates = [
            new google.maps.LatLng(37.772323, -122.214897),
            new google.maps.LatLng(21.291982, -157.821856),
            new google.maps.LatLng(-18.142599, 178.431),
            new google.maps.LatLng(-27.46758, 153.027892)
        ];
        var flightPath = new google.maps.Polyline({
          path: flightPlanCoordinates,
          strokeColor: "#FF0000",
          strokeOpacity: 1.0,
          strokeWeight: 2
        });
    
       flightPath.setMap(map);
      }
    </script>
    </head>
    <body onload="initialize()">
      <div id="map_canvas"></div>
    </body>
    </html>
    

    【讨论】:

    • 抱歉,我必须澄清一下,我需要用 C# 代码构建地图,而不是网站。不过谢谢!
    • 好的。对我来说,我在网络表单上显示它,我使用 Google javascript API for MAP 加载了地图,并且可以显示它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多