如何在Asp.Net网站上显示谷歌地图的纬度和经度 [英] How Do I Show Google Map With Latitude And Longitude In Asp.Net Website

查看:100
本文介绍了如何在Asp.Net网站上显示谷歌地图的纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="mapsettings.aspx.cs" Inherits="mapsettings" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

   <script type="text/javascript"

src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
    function initialize() {
        var lat = document.getElementById('txtlat').value;
        var lon = document.getElementById('txtlon').value;
        var myLatlng = new google.maps.LatLng(lat, lon) // This is used to center the map to show our markers
        var mapOptions = {
            center: myLatlng,
            zoom: 6,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            marker: true
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        var marker = new google.maps.Marker({
            position: myLatlng
        });
        marker.setMap(map);
    }
</script>
    
    
    
     <form id="form1"  runat="server">
<table>
<tr>
<td>Enter Latitude:</td>
<td><input type="text" id="txtlat" value="13.053147716796578" /> </td>
</tr>
<tr>
<td>Enter Longitude:</td>
<td><input type="text" id="txtlon" value="80.2501953125" /> </td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Submit"  önclick="javascript: initialize()" /> </td>
</tr>
</table>
<div id="map_canvas" style="width: 500px; height: 400px"></div>
</form>





当我运行此代码时,我得到一个错误,帮我修复它。

一个页面只能有一个服务器端的Form标签。



描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的更多信息。



异常详细信息:System.Web.HttpException:一个页面只能有一个服务器端的Form标签。



源错误:



在执行当前Web请求期间生成了未处理的异常。有关除外地和位置的信息可以使用下面的异常堆栈跟踪来识别离子。



when i run this code i get an error help me to fix it.
A page can have only one server-side Form tag.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

推荐答案

这是您的问题的解决方案。请试一试。 :)



Here is the solution for your problem.Please try it. :)

引用:

它确实只允许有一个,可见,服务器表单在一个页面上(甚至与主页面结合使用)。



所以只需删除< form id =form1runat =server>和结束< / form>标签,你应该很高兴。

it's indeed only allowed to have one, visible, server form on one page (even in combination with a master page).

So simply remove <form id="form1" runat="server"> and the closing </form> tag and you should be good to go.



另一个链接:



一个页面只能有一台服务器 - 表格标签。 [ ^ ]


Another link :

A page can have only one server-side Form tag.[^]


这篇关于如何在Asp.Net网站上显示谷歌地图的纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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