[英]Google map in ASP.Net MVC3
i want to implement Google map in my ASP.NET MVC3 application. 我想在我的ASP.NET MVC3应用程序中实现Google地图。 i already have Google map code and i want to add Get Direction for any specific City or Country, means i want to add a text-Box in View(HTML) where is enter the "Delhi" and click the GetDirection button then map will show the Delhi in India Map. 我已经有了Google地图代码,并且想为任何特定的城市或国家/地区添加“获取路线”,这意味着我想在View(HTML)中添加一个文本框,在其中输入“ Delhi”并单击“ GetDirection”按钮,然后地图将显示印度德里地图。
my Google Map Code in View(Razor) is below:- 我在View(Razor)中的Google地图代码如下:-
@{
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>
so help to add the GetDirection on my application 所以帮助在我的应用程序上添加GetDirection
If you want to locate a place on the map depending on the location name, you will need the Geocoding service- https://developers.google.com/maps/documentation/javascript/geocoding 如果要根据位置名称在地图上定位,则需要地理编码服务-https ://developers.google.com/maps/documentation/javascript/geocoding
Have a reading of the documentation for Geocoding and you will be able to achieve what you are looking for. 阅读有关地址解析的文档,您将能够实现所需的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.