静谷歌地图不asp.net中工作 [英] Static google maps dont work in asp.net

查看:198
本文介绍了静谷歌地图不asp.net中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成一个图包括大量的信息,并在幅上的行。
我尝试运用在它产生的图像静态谷歌地图,并快速load.i尝试应用下面的例子,但它不desiply地图的 http://en.googlemaps.subgurim.net/ejemplos/ejemplo_999999_Static_Map.aspx 。如何我可以使它在asp.net web表单工作?

i want to generate a map including large amount of information and lines on a web. i try to apply static google maps in which it generates as image and it fast to load.i try to apply the following example but it doesnt desiply the map http://en.googlemaps.subgurim.net/ejemplos/ejemplo_999999_Static_Map.aspx .how can i make it work in asp.net web form?

<%@ 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" />

推荐答案

确定这里就是我的工作。我打算在我自己的网站(不是谷歌)打开谷歌地图的用户在他的ADRESS(家庭,工作和另一不会忽略)移动标记。然后他/她记录这个标记的地方到ADRESS台服务器上。当其他用户打开他的网页,他们可以看到链接按钮在地图上显示。当他们点击该按钮Explorer将打开一个谷歌地图(如果你愿意,你可以在你自己网页的div做到这一点),他们可以看到标记标记和说明。我没有用同样的方式设计在我的项目行,但你可以广告它们。

Ok here is my work. I intended to open a google map in my own web site (not in google) to the user to move a marker on his adress (home, work and for another adresses). and then he/she is recording this marker place to the adress table on the server. when the other user opens his page they can see a "show on the map" link button. when they click the button explorer opens a google map (if you want you can do it in a div in your self page) and they can see the markers and descriptions about markers. I did not design lines in my project but you can ad them with the same way.

这code的另一个propertie是 - 谁增加了他/她的寻址可以找到写他/她的地址到一个文本框ADRES和使用谷歌调查机制的用户。于是,他/她可以将标记easiliy。

Another propertie of this code is the user -who adds his/her address- can find the adres with writing his/her address to a text box and uses google finding mechanism. So he/she can place the marker easiliy.

我用java和VB code。但是,由JavaScript code becouse谷歌subgrim处理的重要部分completaly的java:)

i used java and vb code. But the important section handled by javascript code becouse google subgrim is completaly java :)

下面是完整提到的JavaScript code。

Here is complete javascript code that mentioned.

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('', '');
}

有在code一些土耳其的话,觉得他们就像名字。和Web服务code:

there is some turkish words in code, think them just as names. And the web service code:

<WebMethod()> _
    Public Function koordinatekle(ByVal _adres_tipi As String, ByVal _lat As Double, ByVal _lng As Double, ByVal _kull_adi As String) As String
        Try
            Dim _id As Integer = Val(_adres_tipi.Substring(_adres_tipi.IndexOf("-(ID:") + 5))
            If Left(_adres_tipi, 2) = "An" Then
                Dim sorgu = (From p In tablolar.genel_bilgilers Where p.kullanici_adi = _kull_adi Select p).First

                sorgu.lat = _lat
                sorgu.lon = _lng
                tablolar.SubmitChanges()
            End If
            If Left(_adres_tipi, 2) = "Ek" Then
                Dim sorgu = (From p In tablolar.free_texts Where p.id = _id Select p).First

                sorgu.lat = _lat
                sorgu.lon = _lng
                tablolar.SubmitChanges()
            End If
            Return 1
        Catch ex As Exception
            Return ex.Data.ToString
        End Try
    End Function

JavaScript的code为了记录一个div元素上选定标记的地方调用这个服务。

javascript code calls this service in order to record the selected marker place on a div element.

我用jQuery的不要忘记,因为它简化了工作这么多。首先,它似乎coplicated但很简单。让我来解释吧。

I used jquery dont forget because it eases the works so much. First it seems coplicated but very simple. Let me explain it.

的onload 函数初始化地图。创建一个地理codeR 查找输入的地址。创建地图div元素上的地图。这张地图上创建了一个标记,并设置了标记拖动事件侦听器。

onload function initialize the map. creates a geocoder for finding entered address. creates a map on "map" div element. creates a marker on this map and sets a listener for marker drag event.

codeaddress 函数试图找到它是由用户输入的地址。这一重要功能:

codeaddress function tries to find the address which is entered by user. the important function of this:

geocoder.geocode({ 'address': address }, function (results, status) {....

该功能发送数据ADRES谷歌和尝试得到ADRES的坐标。

this function sends the adres data to google and try to gets the coordinates of adres.

另一个功能只是规定的数据,并通过网络服务将它们发送到服务器。

another functions just sets the data and sends them to the server via a web services.

我希望这可以帮助...

I hope this can help...

如果它工作,不要忘记投票我:)谢谢。

if it works don't forget vote me :) thanks.

不会:我假设你必要的谷歌subgrim键和必要的dll文件(GMaps.dll)添加到您的PROCET

NOT: I assume that you add the necessary google subgrim keys and necessary dll files (GMaps.dll) to your procet.

这篇关于静谷歌地图不asp.net中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆