Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
静态谷歌地图在asp.net中不起作用_Asp.net_Google Maps_Google Maps Api 3_Subgurim Maps - Fatal编程技术网

静态谷歌地图在asp.net中不起作用

静态谷歌地图在asp.net中不起作用,asp.net,google-maps,google-maps-api-3,subgurim-maps,Asp.net,Google Maps,Google Maps Api 3,Subgurim Maps,我想在网上生成一张包含大量信息和线条的地图。 我尝试应用静态谷歌地图,它以图像的形式生成并快速加载。我尝试应用以下示例,但它不设计地图。如何使其在asp.net web表单中工作 <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="PlantDiseasesSystem.WebForm3" %

我想在网上生成一张包含大量信息和线条的地图。 我尝试应用静态谷歌地图,它以图像的形式生成并快速加载。我尝试应用以下示例,但它不设计地图。如何使其在asp.net web表单中工作

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="PlantDiseasesSystem.WebForm3" %>
<%@ Register assembly="GMaps" namespace="Subgurim.Controles" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p>
    <br />
</p>
<cc1:StaticGMap ID="StaticGMap1" runat="server" />
<br />
<br />
<cc1:StaticGMap ID="StaticGMap2" runat="server" />






好的,这是我的作品。我打算在我自己的网站(不是谷歌)上打开谷歌地图,让用户在他的地址(家、工作和其他地址)上移动一个标记。然后他/她将这个标记位置记录到服务器上的地址表中。当其他用户打开他的页面时,他们可以看到“在地图上显示”链接按钮。当他们点击按钮时,浏览器会打开一个谷歌地图(如果你愿意,你可以在你的自我页面的div中进行),他们可以看到标记和关于标记的描述。我并没有在我的项目设计线,但你可以用同样的方式广告他们

这段代码的另一个特性是,添加地址的用户可以通过将地址写入文本框并使用google查找机制来查找地址。这样他/她可以轻松地放置标记

我使用了java和vb代码。但是javascript代码处理的重要部分,因为google subgrim完全是java:)

下面是前面提到的完整javascript代码

var _id = "";
var _adres = "";
var _kull_adi = "";
var _lat;
var _lng;
var geocoder;
var map; 
var marker;
var koords = new Array();

window.onload = function () {
    geocoder = new google.maps.Geocoder();

    var latlng = new google.maps.LatLng(39.42324,35.27587);
    map = new google.maps.Map(document.getElementById('map'), {
        center: latlng,
        zoom: 6,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: 'Move the marker to the address.',
        draggable: true
    });
    google.maps.event.addListener(marker, 'dragend', function (a) {
        _lat = a.latLng.lat().toFixed(8);
        _lng = a.latLng.lng().toFixed(8);
        $('#mapbilgileri_div').html("Enlem : " + _lat + "</br>Boylam : " + _lng);
    });
};

function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            marker.setMap(null);
            map.setZoom(15);
            map.setCenter(results[0].geometry.location);
            marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location,
                title: 'İşaretçiyi adresinizin üzerine getiriniz.',
                draggable: true
            });
            $('#mapbilgileri_div').html("Enlem : " + results[0].geometry.location.lat().toFixed(8) + "</br>Boylam : " + results[0].geometry.location.lng().toFixed(8));
            _lat = results[0].geometry.location.lat().toFixed(8);
            _lng = results[0].geometry.location.lng().toFixed(8);
            map.setCenter(marker.position);
            marker.setMap(map);
            google.maps.event.addListener(marker, 'dragend', function (a) {
                _lat = a.latLng.lat().toFixed(8);
                _lng = a.latLng.lng().toFixed(8);
                $('#mapbilgileri_div').html("Enlem : " + _lat + "</br>Boylam : " + _lng);
            });
        } else {
            alert("Address couldn't find. Please be sure that you wrote it tuely!: " + status);
        }
    });
}

function set_guid(guid, adres,kull_adi,adres_decoded) {
    _id = guid;
    _adres = adres;
    _kull_adi = kull_adi;
    $('#address').val(adres_decoded);
    $('#adresbilgileri_div').html(_id + "</br>" + _adres);
    $('#mapbilgileri_div').html("Enlem : " + _lat + "</br>Boylam : " + _lng);
    codeAddress();
}

function koordinatekle() {
    if (_id.length > 3 && _lat != undefined && _lng != undefined && _adres.length > 3) {
        WebService.koordinatekle(_id, _lat, _lng, _kull_adi, geri_donus);
    } else {
        alert('Please select an address and coordinate from the map !')
    }
}

function geri_donus(result, eventArgs) {
    if (result = "1") {
        alert("coordinate added successfully.");
    } else {
        alert("Error!");
    }
    __doPostBack('', '');
}
此函数将adres数据发送到google并尝试获取adres的坐标

另一个函数只是设置数据并通过web服务将其发送到服务器

我希望这能帮助

如果有效,别忘了给我投票:)谢谢


不是:我假设您将必要的google子密钥和必要的dll文件(GMaps.dll)添加到您的程序中。

我刚刚完成了这项工作,它第一次工作

WebForm1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Website.WebForm1" %>

<%@ Register TagPrefix="cc1" Namespace="Subgurim.Controles" Assembly="GMaps, Version=4.1.0.5, Culture=neutral, PublicKeyToken=564d55b144e7aa5a" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StaticGMap ID="StaticGMap1" runat="server" Language="en" format="png32" />
        <br />
        <cc1:StaticGMap ID="StaticGMap2" runat="server" Language="en" format="png32" />
    </form>
</body>
</html>
你引用了GMap.dll吗

你编译应用程序了吗

*更新

编辑

我说的是注册,我指的是参考。我要做的是将GMap.dll放入解决方案根目录中名为Libs的文件夹(而不是bin文件夹),然后在Visual Studio中右键单击项目并选择“添加引用…”,然后浏览到Libs文件夹中的.dll文件,选中它,单击几次“确定”。现在构建您的解决方案(按Ctrl+Shift+B组合键)


我们确实需要查看您页面中的代码,如果您在复制时犯了一个小错误,它可能会破坏它。否则,这就像把你的车修好,但不让机修工检查引擎盖下面

你有没有遇到问题的c代码?我在asp.net中嵌入了谷歌地图API 4。。我像我提到的例子一样工作。但是没有生成静态谷歌地图。重复的?没有,我没有注册任何东西,我只是从subgurim下载并嵌入…如果我需要注册…请告诉我怎么做。我没有任何公钥。我的代码中的区别是:但在你的代码中:这是否意味着我没有以正确的方式添加它…还是因为我没有公钥钥匙令牌…我怎么能得到这个钥匙…我问了很多问题,因为我在谷歌地图应用程序中是新的
geocoder.geocode({ 'address': address }, function (results, status) {....
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Website.WebForm1" %>

<%@ Register TagPrefix="cc1" Namespace="Subgurim.Controles" Assembly="GMaps, Version=4.1.0.5, Culture=neutral, PublicKeyToken=564d55b144e7aa5a" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StaticGMap ID="StaticGMap1" runat="server" Language="en" format="png32" />
        <br />
        <cc1:StaticGMap ID="StaticGMap2" runat="server" Language="en" format="png32" />
    </form>
</body>
</html>
public partial class WebForm1 : System.Web.UI.Page
{
    protected override void OnPreLoad(EventArgs e)
    {
        base.OnPreLoad(e);

        LoadMap();
    }

    private void LoadMap()
    {
        GLatLng latLng = new GLatLng(41, -7);

        int colorEnumLength = 11;
        int sizeEnumLength = 3;
        double latStep = -1;
        double lngStep = 0.4;
        string msg = "Subgurim Google Maps";

        int iLat = 0;
        int iLng = 0;

        Random r = new Random();
        foreach (char c in msg)
        {
            if (c == ' ')
            {
                iLat++;
                continue;
            }

            GLatLng latlngAux = latLng + new GLatLng(latStep * iLat + r.NextDouble() * 0.4, lngStep * iLng);

            int randomColor = r.Next(colorEnumLength);
            StaticGMarker.ColorEnum color = (StaticGMarker.ColorEnum)randomColor;

            int randomSize = r.Next(2, sizeEnumLength);
            StaticGMarker.SizeEnum size = (StaticGMarker.SizeEnum)randomSize;

            StaticGMarker staticGMarker = new StaticGMarker(latlngAux, size, color, c);
            StaticGMap1.addStaticGMarker(staticGMarker);

            iLng++;
        }

        StaticPath path = new StaticPath();
        path.colorNet = Color.FromArgb(255, 0, 80);
        path.weight = 5;
        path.alpha = 150;

        path.points.Add(new GLatLng(41, -5));
        path.points.Add(new GLatLng(41, -4));
        path.points.Add(new GLatLng(40, -4));
        path.points.Add(new GLatLng(39, -2));

        StaticGMap1.addStaticPath(path);

        StaticGMap2.setCenter(new GLatLng("Valencia, Spain"));
        GLatLng paris = new GLatLng("Paris");
        GLatLng athens = new GLatLng();
        athens.optionalStringValue = "athens";

        StaticGMap2.addStaticGMarker(new StaticGMarker(paris, new StaticGIcon("http://maps.google.com/mapfiles/kml/shapes/sunny.png")));
        StaticGMap2.addStaticGMarker(new StaticGMarker(athens, new StaticGIcon("http://maps.google.com/mapfiles/kml/shapes/sunny.png", true)));

        StaticPath path2 = new StaticPath();
        path2.fillColorNet = Color.Brown;
        path2.colorNet = Color.ForestGreen;
        path2.weight = 2;
        path2.alpha = 150;
        path2.points.Add(new GLatLng("Berlin"));
        path2.points.Add(new GLatLng("Rome"));
        path2.points.Add(new GLatLng("Morocco"));
        StaticGMap2.Add(path2);
    }
}