English 中文(简体)
从数据库中将多个排线/长点装入角图标的好途径?
原标题:Good way to load multiple lat/long points from a database into google map markers?

我有一个包含多个地址的表格,包括它们的Lat/Long坐标表,我希望将许多标记放在一个直观图上,同时使用p.net网络格式和谷歌地图 Java普V3。

The tutorials show how to add one marker:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Markers

 var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  var myOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  var marker = new google.maps.Marker({
      position: myLatlng, 
      map: map, 
      title:"Hello World!"
  });

我的问题是,在我装上了一套多台地址服务器(编码背后)之后,把这套仪器投入到html,使客户旁遮蔽器能够把收集器和标记放在地图上。

Update

如果I already创建了我的一套,那么,在不打外部文字的情况下,在时间的推移到第html页上,什么是体面的? (将复杂的过滤参数与文字混为一谈,这样我就可以避免。) 我是否真的只是要利用一个护卫机来建造一个含有适当json阵列的javascript功能,然后把这一功能放在网页上? 这将奏效,但似乎并不合适。

最佳回答

你可以采取你所建议的做法。

这是一个非常简单的例子,表明用第3号标书绘制多个标识非常容易:

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>

  <script type="text/javascript">

    var map;

    // Cretes the map
    function initialize() {
      map = new google.maps.Map(document.getElementById( map ), {
        zoom: 10,
        center: new google.maps.LatLng(-33.92, 151.25),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      });
    }

    // This function takes an array argument containing a list of marker data
    function generateMarkers(locations) {
      for (var i = 0; i < locations.length; i++) {  
        new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][1], locations[i][2]),
          map: map,
          title: locations[i][0]
        });
      }
    }
  </script>

</head> 
<body> 
  <div id="map" style="width: 500px; height: 400px;"></div>
</body>
</html>

然后,在<条码>和代号;标签内,你可以把以下文字放在任何地方。

<body> 
  <div id="map" style="width: 500px; height: 400px;"></div>

  <script type="text/javascript">
    window.onload = function () {
      initialize();
      generateMarkers(
        [ Bondi Beach , -33.890542, 151.274856],
        [ Coogee Beach , -33.923036, 151.259052],
        [ Cronulla Beach , -34.028249, 151.157507],
        [ Manly Beach , -33.800101, 151.287478],
        [ Maroubra Beach , -33.950198, 151.259302]
      );
    };
  </script>
</body>

您只需要产生“字面”栏。 由于其余部分是静态的,故由服务器边数据组提供。 确保最后一项内容不会用 com子结束。

问题回答

在这里,我能够从谷歌地图普森诉3小组回来,与数万点人合作,具体地说,检查保罗·库尔琴科共同做什么。 它非常麻烦。

我认为,显而易见的做法将会奏效。 在你开始绘制地图后,你可以向制作长串长坐标的JSON阵列的文字提出同步要求。 根据Steve的建议,该清单将标记放在每个坐标上,或将每个标识交给标识管理人。

如果你有太多标记使这种做法可行,那么你就应当逐步装上标识。 那么,你的任务将是决定何时启动同步请求,为地图的某个次点添加标记。

我想产生的结果 标识功能应如此。 如果是一站式电话, 页: 1 标记功能只能使我具有先经辩论的特点。 因此,我不得不把我的正常阵列变成 j。 它为我工作。

generateMarkers([
 { 0 : Bondi Beach ,  1 :-33.890542,  2 :151.274856},
 { 0 : Coogee Beach ,  1 :-33.923036,  2 :151.259052},
 { 0 : Cronulla Beach ,  1 :-34.028249,  2 :151.157507},
 { 0 : Manly Beach ,  1 :-33.800101,  2 :151.287478},
 { 0 : Maroubra Beach ,  1 :-33.950198,  2 :151.259302}
]);

更新标识:

<script type="text/javascript">
    var arr = [
            [ Bondi Beach , -33.890542, 151.274856],
            [ Coogee Beach , -33.923036, 151.259052],
            [ Cronulla Beach , -34.028249, 151.157507],
            [ Manly Beach , -33.800101, 151.287478],
            [ Maroubra Beach , -33.950198, 151.259302]
    ]
        window.onload = function () {
          initialize();
          generateMarkers(arr);
        };

      </script>




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签