关于谷歌地图api开发遇到的问题

万载小笼包 2013-07-17 04:50:55
本人刚接触谷歌地图api的开发,在参考http://net.tutsplus.com/tutorials/asp-net/asp-net-ajax-server-controls-with-client-side-functionality/这个网站的代码练习的时候 遇到了一个问题 不知道怎么解决
希望有人可以告诉我 原因和处理的方法 谢谢。
提示错误是:程序集“MapControl, Version=1.0.4946.30100, Culture=neutral, PublicKeyToken=null”不包含名称为“MapControl.GoogleMap.js”的 Web 资源。
...全文
575 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
海洋夜之星 2013-07-23
  • 打赏
  • 举报
回复
没问题的话也要给点分嘛……
万载小笼包 2013-07-22
  • 打赏
  • 举报
回复
引用 26 楼 dahaianb 的回复:
原因已经找到,请在上面的图片上显示的MapControl项目里的AssemblyInfo.cs的文件里面的最底下加入一行代码:
[assembly: System.Web.UI.WebResource("MapControl.GoogleMap.js", "application/x-javascript")]
谢谢你的帮助~
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
dahaian@vip.qq.com
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 20 楼 dahaianb 的回复:
一般情况下是调试看看到那句代码出错的,然后跟踪下如果程序没有跳到那个引用的控件去的话就可以确认命名空间有问题了,你现在没办法下断点的话可以按F5执行调式,然后按F11单步走看看,确定哪里出问题了后就比较好排除了……
要不您给我个邮箱帐号 我把代码给您看下 不加断点 F5调试 F11也是灰色的
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
一般情况下是调试看看到那句代码出错的,然后跟踪下如果程序没有跳到那个引用的控件去的话就可以确认命名空间有问题了,你现在没办法下断点的话可以按F5执行调式,然后按F11单步走看看,确定哪里出问题了后就比较好排除了……
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 17 楼 woaizuguo 的回复:
围观
不要围观呀...求助..
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 16 楼 dahaianb 的回复:
看样子好像是命名空间有点问题的啊,你检查看看是不是命名空间不一致?还有你那错误是编译的时候报的错误还是调试运行的时候报的错?
额 弱弱的问下 如何检查命名空间不一致...我看了下发现不了哪里的命名空间有问题 这个程序编译的时候成功,调试运行的时候报错的
se7en 2013-07-19
  • 打赏
  • 举报
回复
围观
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
看样子好像是命名空间有点问题的啊,你检查看看是不是命名空间不一致?还有你那错误是编译的时候报的错误还是调试运行的时候报的错?
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 12 楼 dahaianb 的回复:
调试下看出错在哪里,把那代码发出来看看
这个是ajax服务器控件的代码 GoogleMap.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace MapControl
{
    /// <summary>
    /// ServerControl1 的摘要说明
    /// </summary>
    public class GoogleMap : WebControl,IScriptControl
    {
        private int _Zoom = 8;
        /// <summary>
        /// Gets or sets a value representing the zoom of the map.
        /// </summary>
        public int Zoom
        {
            get { return this._Zoom; }
            set { this._Zoom = value; }
        }

        /// <summary>
        /// Gets or sets the latitude value of the initial center point on the map.
        /// </summary>
        public double CenterLatitude { get; set; }

        /// <summary>
        /// Gets or sets the longitude value of the initial center point on the map.
        /// </summary>
        public double CenterLongitude { get; set; }

        private ScriptManager sm;

        public GoogleMap()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Div;
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            if (!this.DesignMode)
            {
                // Test for ScriptManager and register if it exists
                sm = ScriptManager.GetCurrent(Page);

                if (sm == null)
                    throw new HttpException("A ScriptManager control must exist on the current page.");

                sm.RegisterScriptControl(this);
            }

            base.OnPreRender(e);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if (!this.DesignMode)
                sm.RegisterScriptDescriptors(this);

            base.Render(writer);
        }

        public IEnumerable<ScriptDescriptor>  GetScriptDescriptors()
        {
            ScriptControlDescriptor descriptor = new ScriptControlDescriptor("MapControl.GoogleMap", this.ClientID);
            descriptor.AddProperty("zoom", this.Zoom);
            descriptor.AddProperty("centerLatitude", this.CenterLatitude);
            descriptor.AddProperty("centerLongitude", this.CenterLongitude);
            yield return descriptor;
        }

        // 生成脚本引用
        public IEnumerable<ScriptReference> GetScriptReferences()
        {
            yield return new ScriptReference("MapControl.GoogleMap.js", this.GetType().Assembly.FullName);
        }
    }
}
这个是GoogleMap.js
/// <reference name="MicrosoftAjax.js"/>


Type.registerNamespace("MapControl");

MapControl.GoogleMap = function (element) {
    MapControl.GoogleMap.initializeBase(this, [element]);

    this._zoom = null;
    this._centerLatitude = null;
    this._centerLongitude = null;
    //    this._markers = null;

    this._mapObj = null;
}

MapControl.GoogleMap.prototype = {
    initialize: function () {
        MapControl.GoogleMap.callBaseMethod(this, 'initialize');

        // 在此处添加自定义初始化
        this.createMap();
    },
    dispose: function () {
        //在此处添加自定义释放操作
        MapControl.GoogleMap.callBaseMethod(this, 'dispose');
    },
    get_zoom: function () {
        return this._zoom;
    },
    set_zoom: function (value) {
        if (this._zoom !== value) {
            this._zoom = value;
            this.raisePropertyChanged("zoom");
        }
    },
    get_centerLatitude: function () {
        return this._centerLatitude;
    },
    set_centerLatitude: function (value) {
        if (this._centerLatitude !== value) {
            this._centerLatitude = value;
            this.raisePropertyChanged("centerLatitude");
        }
    },
    get_centerLongitude: function () {
        return this._centerLongitude;
    },
    set_centerLongitude: function (value) {
        if (this._centerLongitude !== value) {
            this._centerLongitude = value;
            this.raisePropertyChanged("centerLongitude");
        }
    },
    createMap: function () {
        // Set the center point, zoom, and type of map
        var centerPoint = new google.maps.LatLng(this.get_centerLatitude(), this.get_centerLongitude());
        var options = {
            zoom: this.get_zoom(),
            center: centerPoint,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        // Create the map, using the above options
        this._mapObj = new google.maps.Map(this._element, options);
    } 
}
    MapControl.GoogleMap.registerClass('MapControl.GoogleMap', Sys.UI.Control);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
这个是ASP.NET网站Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MapControlTest._Default" %>

<%@ Register Namespace="MapControl" TagPrefix="mc" Assembly="MapControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManager1">
    </asp:ScriptManager>
    <div>
    <mc:GoogleMap ID="GoogleMap1" runat="server" CenterLatitude="36.1658" CenterLongitude="-86.7844"
            Width="500" Height="500">
            </mc:GoogleMap>
    </div>
    </form>
</body>
</html>
就是这三部分代码
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
调试下看出错在哪里,把那代码发出来看看
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 10 楼 dahaianb 的回复:
你查看下成功例子的webconfig有没有添加对mapcontrol的引用,有的话照着他那样的方法也添加进去

我发现成功例子的webconfig东西很少


但是我自己写的例子的webconfig多出了好多 这问题到底出在哪..
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表可以在
machine.config.comments 中找到,该文件通常位于
\Windows\Microsoft.Net\Framework\vx.x\Config 中
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
设置 compilation debug="true" 可将调试符号插入到
已编译的页面。由于这会
影响性能,因此请仅在开发过程中将此值
设置为 true。
-->
<compilation debug="false">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<!--
通过 <authentication> 节可以配置
安全身份验证模式,ASP.NET
使用该模式来识别来访用户身份。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节
可以配置相应的处理步骤。具体而言,
开发人员通过该节可配置要显示的 html 错误页,
以代替错误堆栈跟踪。

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
system.webServer 节是在 Internet Information Services 7.0 下运行 ASP.NET AJAX
所必需的。对早期版本的 IIS 来说则不需要此节。
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
你查看下成功例子的webconfig有没有添加对mapcontrol的引用,有的话照着他那样的方法也添加进去
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 7 楼 dahaianb 的回复:
那是版本问题吧,你右击那个mapcontrol 的dll属性看下版本是哪个版本的,是编译的时候报这个错误么?调式运行的时候在哪句报的错?
调试和编译的时候都报这样的错误 还有就是我对比了正确的例子 发现webconfig不一样 这是我的webconfig 这个是可以运行的成功例子的webconfig 加断点的话 我都不知道该加到哪
cpeng123 2013-07-19
  • 打赏
  • 举报
回复
本来想回答你的,刚做了google地图api的,然后看你找到原因了,自己结贴哈
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
原因已经找到,请在上面的图片上显示的MapControl项目里的AssemblyInfo.cs的文件里面的最底下加入一行代码:
[assembly: System.Web.UI.WebResource("MapControl.GoogleMap.js", "application/x-javascript")]

万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 24 楼 dahaianb 的回复:
晕,要不你把那程序当资源发到你的csdn资源里,在我地址给我我去下载看看,因为现在完全上不了其他的网站……
你好,我把它发布成资源了,麻烦你帮我看一下,谢谢 http://download.csdn.net/detail/i_popular/5783809
海洋夜之星 2013-07-19
  • 打赏
  • 举报
回复
晕,要不你把那程序当资源发到你的csdn资源里,在我地址给我我去下载看看,因为现在完全上不了其他的网站……
万载小笼包 2013-07-19
  • 打赏
  • 举报
回复
引用 22 楼 dahaianb 的回复:
dahaian@vip.qq.com
你好,我发了两封邮件到你邮箱...
加载更多回复(8)
内容简介   本书内容上涵盖了用android开发的大部分场景,从android基础介绍、环境搭建、sdk介绍、market使用,到应用剖析、组件介绍、实例演示等方面。从技术实现上,讲解了5个android平台下的完整综合实例及源代码分析,分别是rss阅读器、基于google map的个人gps、豆瓣网(web 2.0)客户端、在线音乐播放器、手机信息查看助手。本书注重对实际动手能力的指导,在遵循技术研发知识体系的严密性同时,在容易产生错误、不易理解的环节配以了翔实的开发情景截图,并将重要的知识点和开发技巧以“小实验”、“小提醒”、“小知识”、“注意”等的活泼形式呈现给读者。在程序实例的讲解方面,主要将实例安插在android开发的精髓知识章节,这为初学者学习与实践结合提供了很好的指导。.    本书配套有400多分钟的全程开发视频光盘,指导读者快速、无障碍地学通android实战开发技术。..    本书适合具备一定软件开发经验,想快速进入android开发领域的程序员;具备一些手机开发经验的开发者和android开发爱好者学习用书;也适合作为相关培训学校的android培训教材。... 目录 第1章 掀起你的盖头来——初识android. 1 1.1 认识android 1 1.2 android的背景 2 1.2.1 android的历史 2 1.2.2 android的发展 2 1.3 我的android我做主 2 1.3.1 开发基于android平台的应用 3 1.3.2 参加android开发者大赛 3 1.3.3 个人英雄主义再现——得到更多人的认可和尊重 3 1.3.4 获得应有的收益——android market 3 1.4 真实体验——android模拟器 4 1.4.1 模拟器概述 4 1.4.2 模拟器和真机的区别 4 1.4.3 模拟器使用注意事项 4 1.5 更上一层楼——加入android开发社区 5 1.6 本章小结 6 第2章 工欲善其事 必先利其器——搭建android开发环境 7 2.1 开发android应用前的准备 7 2.1.1 android开发系统要求 7 2.1.2 android软件开发包 7 .2.1.3 其他注意事项 8 2.2 windows开发环境搭建 8 2.2.1 jdk、eclipse、android sdk软件安装 8 2.2.2 sdk的家在哪里——设定android sdk home 14 2.2.3 真的准备好了吗——开发环境验证 14 2.2.4 创建android 虚拟设备(avd) 15 2.3 linux一族——ubuntu开发环境搭建 17 2.3.1 java、eclipse和adt插件安装 17 2.3.2 设定android sdk home 23 2.4 mac os一族——苹果开发环境搭建 24 2.5 本章小结 24 第3章 清点可用资本——android sdk介绍 25 3.1 android sdk 基础 25 3.2 深入探寻android sdk的密码 25 3.2.1 android sdk目录结构 25 3.2.2 android.jar及内部结构 27 3.2.3 sdk文档及阅读技巧 27 3.2.4 先来热热身——android sdk例子解析 28 3.2.5 sdk提供的工具介绍 31 3.3 android典型包分析 33 3.3.1 开发的基石——android api核心开发包介绍 33 3.3.2 拓展开发外延——android可选api介绍 34 3.4 本章小结 34 第4章 赚钱的市场——android market及应用发布 35 4.1 google market产生背景与目的 35 4.2 体验“选货”的乐趣——在g1上体验market的使用 35 4.3 android开发活动及特色应用 37 4.3.1 开发应用的领域 37 4.3.2 android market特色应用一览 38 4.4 你也可以做东家——申请market账号 43 4.4.1 卖东西要先入伙——准备工作 43 4.4.2 入伙过程——申请 44 4.5 开张了——在market上发布应用 45 4.5.1 发布时可能遇到的错误 45 4.5.2 卖东西也要签名——生成签名文件 46 4.5.3 打包、签名、发布应用 48 4.6 本章小结 51 第5章 千里之行 始于足下——第一个应用helloworld 52 5.1 helloworld应用分析 52 5.1.1 新建一个andr

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧