【问题标题】:Google map in ASP.Net MVC3ASP.Net MVC3 中的谷歌地图
【发布时间】:2012-11-28 08:54:00
【问题描述】:

我想在我的 ASP.NET MVC3 应用程序中实现 Google 地图。我已经有谷歌地图代码,我想为任何特定的城市或国家添加获取方向,这意味着我想在视图(HTML)中添加一个文本框,输入“德里”并单击获取方向按钮,然后地图将显示印度德里地图。

我在 View(Razor) 中的谷歌地图代码如下:-

@{
    ViewBag.Title = "Google Map";
}
@section Scripts { 
    <script type="text/javascript"src="http://maps.google.com/maps/api/js?sensor=false"></script> 
} 
@section Styles { 
    html { height: 100% } 
    body { height: 100%; margin: 0px; padding: 0px } 
    #map_canvas { height: 80% } 
} 

<h2>Google Maps</h2>
<div id="map_canvas" style="width:400px; height:300px"></div>
<script type="text/javascript">
    function initialize() 
    {
        var latlng = new google.maps.LatLng(40.716948, -74.003563);
        var options = { zoom: 14, center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), options);
    }
    $(function () {
        initialize();
    }); 

</script> 

所以帮助在我的应用程序上添加 GetDirection

【问题讨论】:

    标签: javascript asp.net-mvc-3 google-maps google-maps-api-3


    【解决方案1】:

    如果您想根据位置名称在地图上定位某个地点,则需要地理编码服务-https://developers.google.com/maps/documentation/javascript/geocoding

    阅读地理编码的文档,您将能够实现您所寻找的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 1970-01-01
      • 2020-09-02
      • 2012-05-21
      • 1970-01-01
      相关资源
      最近更新 更多