• <small id='dfN93'></small><noframes id='dfN93'>

      <bdo id='dfN93'></bdo><ul id='dfN93'></ul>

  • <legend id='dfN93'><style id='dfN93'><dir id='dfN93'><q id='dfN93'></q></dir></style></legend>
        <i id='dfN93'><tr id='dfN93'><dt id='dfN93'><q id='dfN93'><span id='dfN93'><b id='dfN93'><form id='dfN93'><ins id='dfN93'></ins><ul id='dfN93'></ul><sub id='dfN93'></sub></form><legend id='dfN93'></legend><bdo id='dfN93'><pre id='dfN93'><center id='dfN93'></center></pre></bdo></b><th id='dfN93'></th></span></q></dt></tr></i><div id='dfN93'><tfoot id='dfN93'></tfoot><dl id='dfN93'><fieldset id='dfN93'></fieldset></dl></div>
        <tfoot id='dfN93'></tfoot>

        向谷歌地图添加多个标记

        时间:2023-06-14

            <bdo id='xEEmS'></bdo><ul id='xEEmS'></ul>

              <i id='xEEmS'><tr id='xEEmS'><dt id='xEEmS'><q id='xEEmS'><span id='xEEmS'><b id='xEEmS'><form id='xEEmS'><ins id='xEEmS'></ins><ul id='xEEmS'></ul><sub id='xEEmS'></sub></form><legend id='xEEmS'></legend><bdo id='xEEmS'><pre id='xEEmS'><center id='xEEmS'></center></pre></bdo></b><th id='xEEmS'></th></span></q></dt></tr></i><div id='xEEmS'><tfoot id='xEEmS'></tfoot><dl id='xEEmS'><fieldset id='xEEmS'></fieldset></dl></div>

              <small id='xEEmS'></small><noframes id='xEEmS'>

                    <tbody id='xEEmS'></tbody>
                • <tfoot id='xEEmS'></tfoot><legend id='xEEmS'><style id='xEEmS'><dir id='xEEmS'><q id='xEEmS'></q></dir></style></legend>
                • 本文介绍了向谷歌地图添加多个标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望为 Google 地图 v3 API 中列出的每个企业添加标记在这个页面上在右上角.

                  I'm looking to add markers for each business listed to a Google map v3 API on this page in the top right hand corner.

                  我不确定如何为多个邮政编码执行此操作,但我们目前在 个别业务页面对存储在数据库中的动态邮政编码使用 URLencode.

                  I'm not sure how to do this for multiple postcodes, but the one we currently use on the individual business pages use a URLencode for the dynamic postcodes stored in the database.

                  这是我们用于各个页面的代码:

                  Here's the code we use for the individual pages:

                  <script src="http://maps.googleapis.com/maps/api/js?q=London&key=AIzaSyBaPEDyFbbnWjtvT8W3UBOM34Y7g6vK69A&sensor=false"></script>
                  
                      var map;
                      function initialize() {
                        var mapOptions = {
                          zoom: 15,
                          center: new google.maps.LatLng(51.511214,-0.119824),
                          mapTypeId: google.maps.MapTypeId.ROADMAP
                        };
                        var geolocate = function(address, callback) {
                              $.ajax({
                                      url: "http://maps.googleapis.com/maps/api/geocode/json",
                                      data: {
                                          "sensor": true,
                                          "address": address
                                      },
                                      dataType: "json",
                                      success: function(d) {
                                          if (d.status == "ZERO_RESULTS") callback(false);
                                          if (d.results && d.results[0] && d.results[0].geometry) {
                                              callback({
                                                  "ne": d.results[0].geometry.bounds.northeast,
                                                  "sw": d.results[0].geometry.bounds.southwest,
                                                  "center": d.results[0].geometry.location
                                              });
                                          }
                                          else callback(false);
                                      }
                                  });
                        };
                        map = new google.maps.Map(document.getElementById('map-canvas'),
                            mapOptions);
                        geolocate("<%=server.URLEncode(""&rsAdvert("ContactPostcode"))%>", function(c) {
                              map.setCenter(new google.maps.LatLng(c.center.lat, c.center.lng));
                       });
                      }
                      google.maps.event.addDomListener(window, 'load', initialize);
                  
                  $('#myModal').on('shown', function () {
                    google.maps.event.trigger(map, 'resize');
                  })
                  

                  该页面的邮政编码是在 ASP 中生成的:

                  The postcodes for that page are generated in ASP:

                      if rsDB_Ads("ContactPostcode") <> "" then
                          strTempHTML = "[ContactPostcode]"
                          strDB_AdvertItem = Replace(strDB_AdvertItem, "<!--ContactPostcode-->", strTempHTML)
                      Else
                          strDB_AdvertItem = Replace(strDB_AdvertItem, "<!--ContactPostcode-->", "")
                      End if
                  

                  希望有人可以提供帮助..

                  Hoping someone can help..

                  推荐答案

                  只是开始,这里是如何管理多个标记.(将代码复制并粘贴到 html 文件中,它就可以工作了......)然后您可以通过经典的 asp 从数据库等中写出位置来调整代码:

                  Just for a start, here is how to manage multiple markers. (copy & Paste the code into a html file and it works ...) You can then adapt the code by writing out the locations from a db etc. via classic asp:

                      <!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>
                      </head>
                      <body>
                        <div id="map" style="width: 1000px; height: 1000px;"></div>
                  
                        <script type="text/javascript">
                          var locations = [
                            ['Stadtbibliothek Zanklhof', 47.06976, 15.43154, 1],
                            ['Stadtbibliothek dieMediathek', 47.06975, 15.43116, 2],
                            ['Stadtbibliothek Gsting', 47.09399, 15.40548, 3],
                            ['Stadtbibliothek Graz West', 47.06993, 15.40727, 4],
                            ['Stadtbibliothek Graz Ost', 47.06934, 15.45888, 5],
                            ['Stadtbibliothek Graz Süd', 47.04572, 15.43234, 6],
                            ['Stadtbibliothek Graz Nord', 47.08350, 15.43212, 7],
                            ['Stadtbibliothek Andritz', 47.10280, 15.42137, 8]
                          ];
                  
                          var map = new google.maps.Map(document.getElementById('map'), {
                            zoom: 13,
                            center: new google.maps.LatLng(47.071876, 15.441456),
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                          });
                  
                          var infowindow = new google.maps.InfoWindow();
                  
                          var marker, i;
                  
                          for (i = 0; i < locations.length; i++) {
                            marker = new google.maps.Marker({
                              position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                              map: map
                            });
                  
                            google.maps.event.addListener(marker, 'click', (function(marker, i) {
                              return function() {
                                infowindow.setContent(locations[i][0]);
                                infowindow.open(map, marker);
                              }
                            })(marker, i));
                          }
                        </script>
                      </body>
                      </html>
                  

                  这篇关于向谷歌地图添加多个标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ActiveX 日历控件在 Windows 7 中不起作用 下一篇:如何在经典的 ASP Web 应用程序之上集成 WebSockets?

                  相关文章

                  1. <i id='9fEdw'><tr id='9fEdw'><dt id='9fEdw'><q id='9fEdw'><span id='9fEdw'><b id='9fEdw'><form id='9fEdw'><ins id='9fEdw'></ins><ul id='9fEdw'></ul><sub id='9fEdw'></sub></form><legend id='9fEdw'></legend><bdo id='9fEdw'><pre id='9fEdw'><center id='9fEdw'></center></pre></bdo></b><th id='9fEdw'></th></span></q></dt></tr></i><div id='9fEdw'><tfoot id='9fEdw'></tfoot><dl id='9fEdw'><fieldset id='9fEdw'></fieldset></dl></div>

                      <bdo id='9fEdw'></bdo><ul id='9fEdw'></ul>

                    <small id='9fEdw'></small><noframes id='9fEdw'>

                    1. <tfoot id='9fEdw'></tfoot>
                      <legend id='9fEdw'><style id='9fEdw'><dir id='9fEdw'><q id='9fEdw'></q></dir></style></legend>