如何在asp.net中添加静态谷歌地图 [英] How to Add a static google map in asp.net
本文介绍了如何在asp.net中添加静态谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的项目中添加了一个谷歌地图它是可滚动的我需要在我的页面中使用静态地图,但它应该可以缩放。我的代码如下:
.aspx页面:
I have added a google map in my project it was scrollable i need a static map in my page but it should zoomable. My code is given below...
.aspx Page:
<div class="paddingBlk">
<div id="map" class="map mapDiv">
</div>
<input type="hidden" id="txthLatitude" runat="server" />
<input type="hidden" id="txthLongitude" runat="server" />
和Js代码是这样的:
And Js code is like this:
function initialize() {
try {
var lat = document.getElementById("txthLatitude").value;
var lng = document.getElementById("txthLongitude").value;
var myLatlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: 13,
center: myLatlng,
navigationControl: false,
mapTypeControl: false,
scrollwheel: false,
disableDoubleClickZoom: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "DirectStay Property"
});
} catch (e) {
}
}
谢谢..
Thanks..
推荐答案
在头部,只需添加对谷歌地图的引用和这样的jquery文件---
函数initialize() {
尝试{
var lat = document.getElementById(txthLatitude)。value;
var lng = document.getElementById(txthLongitude ).value;
var myLatlng = new google.maps.LatLng(lat,lng);
var myOptions = {
zoom:13,
center:myLatlng,
disableDoubleClickZoom:true,
mapTypeId:google.maps.MapTypeId。 ROADMAP
}
var map = new google.maps.Map(document.getElementById( map),myOptions);
var marker = new google.maps.Marker({
position:myLatlng,
地图:地图,
标题:DirectStay Property
});
} catch(e){
}
}
//现在,添加一个简单的div来显示你的谷歌地图
In the head section, just add reference to google map and jquery files like this---
function initialize() {
try {
var lat = document.getElementById("txthLatitude").value;
var lng = document.getElementById("txthLongitude").value;
var myLatlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: 13,
center: myLatlng,
disableDoubleClickZoom: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "DirectStay Property"
});
} catch (e) {
}
}
// now, add a simple div to show your google map into it
这篇关于如何在asp.net中添加静态谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文