【发布时间】:2016-09-22 22:34:48
【问题描述】:
我正在使用带有 ASP 的 VB。我有一个 ASP Image 控件,其中包含一个图像,在这种情况下,它是从 Google Maps 引入的静态地图。我想使用 VB 代码将该图像下载到图像(bmp、jpg 或任何东西)。图像驻留在客户端的 asp:Image 对象中。只需要使用来自服务器端的代码下载图像。如有必要,我可以在客户端使用 JS 来执行此操作。在这种情况下,我仍然想看看是否有人知道如何做到这一点。
这是我的 javascript 代码,用于将页面上显示的地图加载到 asp:image 对象。这部分效果很好。只需要将图像保存为文件。此函数正在使用的页面上的先前代码中有预定义的变量,包括“地图”、“地图选项”、“边界”和“标记”
function Export() {
map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
//URL of Google Static Maps.
var staticMapUrl = "https://maps.googleapis.com/maps/api/staticmap";
//Set the Google Map Center.
staticMapUrl += "?center=" + mapOptions.center.G + "," + mapOptions.center.K;
//Set the Google Map Size.
staticMapUrl += "&size=220x350";
//Set the Google Map Zoom.
staticMapUrl += "&zoom=" + mapOptions.zoom;
//Set the Google Map Type.
staticMapUrl += "&maptype=" + mapOptions.mapTypeId;
//Loop and add Markers.
for (var i = 0; i < markers.length; i++) {
var data = markers[i];
if (data.pointNumber !== null) {
var labelNumber = data.pointNumber;
var labelString = labelNumber.toString();
var iconName = 'm' + labelString + '.png';
var roundLat = data.latitude; // + .00003;
var roundLon = data.longitude; // + .000005;
var myLatlng = new google.maps.LatLng(roundLat, roundLon);
var image =
{
url: 'ImagesForPoints/' + iconName,
scaledSize: new google.maps.Size(35, 48), // scaled size
//size: new google.maps.Size(53, 73),
//origin: new google.maps.Point(0,0),
//anchor: new google.maps.Point(30, 69)
anchor: new google.maps.Point(19, 45)
};
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: image,
});
bounds.extend(marker.position);
map.fitBounds(bounds);
}
}
//Display the Image of Google Map.
var imgMap = document.getElementById("imgMap");
imgMap.src = staticMapUrl;
imgMap.style.display = "block";
}
【问题讨论】:
-
您只需要在 asp:image 对象中显示图像吗?
-
您能否添加一些示例代码来演示您的问题以及您目前的情况?它会让你更清楚你被困在哪些部分。
-
我可以在页面上的图像对象中显示图像。我要做的就是将图像保存为某个文件。或者,如果我可以将它作为文件流获取,我可以用它做任何我需要的事情。我似乎无法做到这一点。我将发布有关它如何进入屏幕上的图片对象的代码。 @toto
-
您能否提供一个示例网址,您可以在其中获取图片谷歌地图?
-
这是我的代码。
code
标签: javascript asp.net vb.net