C# 谷歌街景或必应街边URL';s使用纬度和经度
我有纬度和经度坐标,一直在尝试在web浏览器实例中打开Google streetview或Bing streetside 我已经设法做到这一点,使用谷歌街景网址如下,但我发现,如果坐标不完全在道路上,它不工作。相反,你会得到一张全世界的地图C# 谷歌街景或必应街边URL';s使用纬度和经度,c#,google-maps,bing-maps,latitude-longitude,google-street-view,C#,Google Maps,Bing Maps,Latitude Longitude,Google Street View,我有纬度和经度坐标,一直在尝试在web浏览器实例中打开Google streetview或Bing streetside 我已经设法做到这一点,使用谷歌街景网址如下,但我发现,如果坐标不完全在道路上,它不工作。相反,你会得到一张全世界的地图 string.Format( "http://maps.google.com/?cbll={0},{1}&cbp=12,0,0,0,5&layer=c", this.Location.Latitude, this.Lo
string.Format(
"http://maps.google.com/?cbll={0},{1}&cbp=12,0,0,0,5&layer=c",
this.Location.Latitude,
this.Location.Longitude)
我想用的坐标是在伦敦,所以几乎都是地图。我想显示最近的街道位置。您应该能够使用以下内容: http://maps.googleapis.com/maps/api/streetview?size=300x300&format=png&fov=90&location={0},{1}&sensor=false
http://maps.googleapis.com/maps/api/streetview?size=300x300&format=png&fov=90&location={0},{1}&sensor=false您应该能够使用如下内容: http://maps.googleapis.com/maps/api/streetview?size=300x300&format=png&fov=90&location={0},{1}&sensor=false
http://maps.googleapis.com/maps/api/streetview?size=300x300&format=png&fov=90&location={0},{1}&sensor=false我过去常常通过URL操作来做很多谷歌地图的事情。直到我发现了从C#
WebBrowser
实例调用JavaScript的能力。我通常使用与WebBrowser
的方法一起调用所需的内容。我发现它的用途更广泛,尽管有时会让人感到痛苦
编辑:很抱歉,我意识到这不一定是对你问题的直接回答,但我发现,除了最基本的地图操作之外,API和JavaScript提供了更好的功能。我过去常常通过URL操作来做很多谷歌地图的事情。直到我发现了从C#
WebBrowser
实例调用JavaScript的能力。我通常使用与WebBrowser
的方法一起调用所需的内容。我发现它的用途更广泛,尽管有时会让人感到痛苦
编辑:很抱歉,我意识到这不一定是对你问题的直接回答,但我发现除了最基本的地图操作之外,API和JavaScript提供了更好的功能。我过去所做的就是这样。我检查街景服务在给定位置50米范围内是否有“全景”。下面是一些完整的JS代码示例,可以按原样工作
<!DOCTYPE html>
<html>
<head>
<title>Streetview</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#streetView { height: 100%; width: 100%; }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
function createStreetMap(strMapCanvasID, intLat, intLong)
{
//create a google latLng object
var streetViewLocation = new google.maps.LatLng(intLat,intLong);
var panorama;
//once the document is loaded, see if google has a streetview image within 50 meters of the given location, and load that panorama
var sv = new google.maps.StreetViewService();
sv.getPanoramaByLocation(streetViewLocation, 50, function(data, status) {
if (status == 'OK') {
//google has a streetview image for this location, so attach it to the streetview div
var panoramaOptions = {
pano: data.location.pano,
addressControl: false,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById(strMapCanvasID), panoramaOptions);
}
else{
//no google streetview image for this location, so hide the streetview div
$('#' + strMapCanvasID).parent().hide();
}
});
return panorama;
}
$(document).ready(function() {
var myPano = createStreetMap('streetView', 51.513016, -0.144424);
});
</script>
</head>
<body>
<div>
<h2>Street View</h2>
<div id="streetView"></div>
</div>
</body>
</html>
我相信C#而不是从$(document.ready(function(){…})中调用createStreetMap
代码>您将使用该方法并执行以下操作:
object[] args = {"streetView",51.513016,-0.144424};
webBrowser1.Document.InvokeScript("createStreetMap",args);
另请参见:我过去所做的事情是这样的。我检查街景服务在给定位置50米范围内是否有“全景”。下面是一些完整的JS代码示例,可以按原样工作
<!DOCTYPE html>
<html>
<head>
<title>Streetview</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#streetView { height: 100%; width: 100%; }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
function createStreetMap(strMapCanvasID, intLat, intLong)
{
//create a google latLng object
var streetViewLocation = new google.maps.LatLng(intLat,intLong);
var panorama;
//once the document is loaded, see if google has a streetview image within 50 meters of the given location, and load that panorama
var sv = new google.maps.StreetViewService();
sv.getPanoramaByLocation(streetViewLocation, 50, function(data, status) {
if (status == 'OK') {
//google has a streetview image for this location, so attach it to the streetview div
var panoramaOptions = {
pano: data.location.pano,
addressControl: false,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById(strMapCanvasID), panoramaOptions);
}
else{
//no google streetview image for this location, so hide the streetview div
$('#' + strMapCanvasID).parent().hide();
}
});
return panorama;
}
$(document).ready(function() {
var myPano = createStreetMap('streetView', 51.513016, -0.144424);
});
</script>
</head>
<body>
<div>
<h2>Street View</h2>
<div id="streetView"></div>
</div>
</body>
</html>
我相信C#而不是从$(document.ready(function(){…})中调用createStreetMap
代码>您将使用该方法并执行以下操作:
object[] args = {"streetView",51.513016,-0.144424};
webBrowser1.Document.InvokeScript("createStreetMap",args);
另请参见:我更感兴趣的是打开谷歌地图页面,这样用户就可以四处浏览。我更感兴趣的是打开谷歌地图页面,这样用户就可以四处浏览。这很有趣。我实际上是从一个Windows应用商店应用程序中编写代码,并启动一个URL来打开web浏览器。我可以将web浏览器控件直接集成到我的页面中,但JavaScript对我来说是一个非常可怕的地方,有没有关于如何实现我的目标的好指南。@user1212017 JavaScript在学习了基础知识后真的没有那么糟糕。在这种情况下,您实际上不需要编写太多的JavaScript(您将不得不使用API编写一些JavaScript),需要技巧的部分是避免跨域调用。如果您以前没有使用过HTML/JavaScript,那么最好从学习两者的基础知识开始,或者在实际的Google地图页面上使用内置的JavaScript函数。使用内置的JavaScript不需要编写任何JavaScript,但我认为它们不会被记录在任何地方,我是通过Chrome的JavaScript控制台获得的。@user1212017是我学习JavaScript和HTML时最好的朋友。他们有很多非常有用的教程,这很有趣。我实际上是从一个Windows应用商店应用程序中编写代码,并启动一个URL来打开web浏览器。我可以将web浏览器控件直接集成到我的页面中,但JavaScript对我来说是一个非常可怕的地方,有没有关于如何实现我的目标的好指南。@user1212017 JavaScript在学习了基础知识后真的没有那么糟糕。在这种情况下,您实际上不需要编写太多的JavaScript(您将不得不使用API编写一些JavaScript),需要技巧的部分是避免跨域调用。如果您以前没有使用过HTML/JavaScript,那么最好从学习两者的基础知识开始,或者在实际的Google地图页面上使用内置的JavaScript函数。使用内置的JavaScript不需要编写任何JavaScript,但我认为它们不会被记录在任何地方,我是通过Chrome的JavaScript控制台获得的。@user1212017是我学习JavaScript和HTML时最好的朋友。他们有很多非常有用的教程。如果我错了,请纠正我,但这看起来完全是用JavaScript编写的。上次我看Google没有.NET API。现在你的编辑只是在它上面添加了JQuery,这对在C#NET应用程序中尝试这样做的人有什么帮助?你之前的一条评论提到“能够从C#WebBrowser实例调用JavaScript”是的,这就是我的答案。但这种能力仅限于网页上已有的功能。如果没有A)由于跨域函数调用而导致异常发生B)对于之前对JavaScript知之甚少或一无所知的人来说,在不学习JavaScript和C)的基础知识的情况下直接使用JQuery是非常困难的)甚至知道如何将整个新函数从C#放入JavaScript答案根本没有解决用户不是从网页而是从.Net进行此操作的事实,因此是不完整的。你只是提供了一个更具体的例子来说明我对d说的话