Google Maps - ASP.Net 中的简单方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/360677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Maps - Easy way in ASP.Net?
提问by Bill
I'm wanting to use google maps and see a million ways to do it on the web. Some are javascript methods and some are asp.net server components with which I have hit and miss luck. What's the easiest and most reliable way using c# and asp.net?
我想使用谷歌地图并在网上看到一百万种方法。有些是 javascript 方法,有些是 asp.net 服务器组件,我用它来碰运气。使用 c# 和 asp.net 的最简单和最可靠的方法是什么?
I have my location data including geocodes in a database. I want to provide users a method to do a lookup for certain locations. From there, my code will provide a table of geocodes to google maps with markers on the map corresponding to the found entries. Users can see each entry and need to be able to tell which is which if multiple rows are returned.
我有我的位置数据,包括数据库中的地理编码。我想为用户提供一种查找特定位置的方法。从那里,我的代码将为谷歌地图提供一个地理编码表,地图上的标记与找到的条目相对应。如果返回多行,用户可以看到每个条目并且需要能够分辨哪个是哪个。
Is there a good way to do this?
有没有好的方法可以做到这一点?
采纳答案by John Sheehan
The Google Maps API is accessed via JavaScript (any server controls are just abstracting this away from you). In the case you described, you would need to dynamically output the required JavaScript to tell the maps API what to display.
Google Maps API 是通过 JavaScript 访问的(任何服务器控件都只是将其从您那里抽象出来)。在您描述的情况下,您需要动态输出所需的 JavaScript 来告诉地图 API 要显示什么。
回答by Ryan Smith
I would recommend using direct JavaScript to create the Google Maps. It's fairly straight forward and then you will be able to understand what's going on behind the scenes.
我建议使用直接 JavaScript 来创建 Google 地图。这是相当直接的,然后您将能够了解幕后发生的事情。
Google has some pretty good tutorials and documentation to get you up and running quick. Once you add one to your site, it will become very easy to setup the rest of the customization that you need.
Google 有一些非常好的教程和文档,可以帮助您快速上手。一旦您将一个添加到您的站点,设置您需要的其余自定义将变得非常容易。
Take a look at this site for examples.
看看这个网站的例子。
回答by Eduardo Molteni
There are a few server controls to do it, like this, but you have to learn how to do things in one way (server control) or another (Javascript Google API).
有一些服务器控件可以做到这一点,就像这样,但您必须学习如何以一种方式(服务器控件)或另一种方式(Javascript Google API)做事。
I recommend using the Google API, since it has more samples all over the web, and you can use new features implemented by Google right after they release them and don't have to wait for the server control developer to do it.
我建议使用 Google API,因为它在网络上有更多示例,并且您可以在 Google 发布后立即使用由 Google 实现的新功能,而不必等待服务器控件开发人员来做。
回答by Stefan
As usual I point to ComponentOne who has a nice SilverLight control for this that can use google-maps or Microsofts Live Maps, it uses Silverlight Deep Zoom to handle it nicely: http://www.componentone.com/SuperProducts/MapsSilverlight/
像往常一样,我指向 ComponentOne,他有一个很好的 SilverLight 控件,可以使用谷歌地图或微软的实时地图,它使用 Silverlight Deep Zoom 来很好地处理它:http: //www.componentone.com/SuperProducts/MapsSilverlight/
Live example: http://demo.componentone.com/Silverlight/Factories/
现场示例:http: //demo.componentone.com/Silverlight/Factories/
(I'm not from ComponentOne, just a satisfied customer) ;)
(我不是来自 ComponentOne,只是一个满意的客户);)
I know you can do it yourself with scripts and other ways, but its just so much more fun to use code allreade written. ;)
我知道您可以使用脚本和其他方式自己完成,但是使用 allread 编写的代码会更有趣。;)
回答by Jason
回答by Bill
BTW: I found a great post here that has an example on how to do a store lookup. Works really well. I recommend!!
顺便说一句:我在这里找到了一篇很棒的帖子,其中有一个关于如何进行商店查找的示例。效果很好。我建议!!
http://blog.donnfelker.com/post/HOWTO-Build-a-Store-Locator-in-ASPNET.aspx
http://blog.donnfelker.com/post/HOWTO-Build-a-Store-Locator-in-ASPNET.aspx
回答by Raj Rao
Check out this example: Data driven Google Maps in ASP.Net
查看此示例:ASP.Net 中的数据驱动的 Google 地图
I used ASP.Net Ajax to create a web-service that is callable from JavaScript. The web-service talks to the database and fills a very basic object. ASP.Net Ajax, then makes the object available to my client javascript. The rest is easy: In the client, you call the webservice from Javascript, read the data returned and populate Google Maps, using simple Google Maps API calls.
我使用 ASP.Net Ajax 创建了一个可从 JavaScript 调用的 Web 服务。Web 服务与数据库对话并填充一个非常基本的对象。ASP.Net Ajax,然后使对象可用于我的客户端 javascript。剩下的很简单:在客户端,您从 Javascript 调用网络服务,读取返回的数据并填充 Google 地图,使用简单的 Google Maps API 调用。
Check out the site at link text
在链接文本处查看网站
回答by Subgurim
Please, try my GoogleMaps control for ASP.NET
回答by Maxim
If you need server-side API, this open-source project can help you much - http://code.google.com/p/google-maps/
如果您需要服务器端 API,这个开源项目可以帮助您很多 - http://code.google.com/p/google-maps/
I helps to query google-maps api and also get links for static maps.
我帮助查询 google-maps api 并获取静态地图的链接。