久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <i id='Pfmud'><tr id='Pfmud'><dt id='Pfmud'><q id='Pfmud'><span id='Pfmud'><b id='Pfmud'><form id='Pfmud'><ins id='Pfmud'></ins><ul id='Pfmud'></ul><sub id='Pfmud'></sub></form><legend id='Pfmud'></legend><bdo id='Pfmud'><pre id='Pfmud'><center id='Pfmud'></center></pre></bdo></b><th id='Pfmud'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Pfmud'><tfoot id='Pfmud'></tfoot><dl id='Pfmud'><fieldset id='Pfmud'></fieldset></dl></div>
  1. <legend id='Pfmud'><style id='Pfmud'><dir id='Pfmud'><q id='Pfmud'></q></dir></style></legend>

        <bdo id='Pfmud'></bdo><ul id='Pfmud'></ul>
    1. <tfoot id='Pfmud'></tfoot>

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

      如何使用傳單 js 在地圖上精確放置 div 元素?

      How to precisely place a div element on a map using leaflet js?(如何使用傳單 js 在地圖上精確放置 div 元素?)
        <tbody id='KuLXF'></tbody>

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

          <legend id='KuLXF'><style id='KuLXF'><dir id='KuLXF'><q id='KuLXF'></q></dir></style></legend><tfoot id='KuLXF'></tfoot>

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

              1. 本文介紹了如何使用傳單 js 在地圖上精確放置 div 元素?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我已經嘗試了這兩種方法,但都無法使其正常工作.我想在多個時區的地圖頂部放置時鐘.我有一個 javascript 來創建時鐘,并將時鐘放在 div 元素中.

                這是我嘗試過的:

                1. 使用 0,0 坐標創建一個點.
                2. 從這里使用 containerPointToLatLng 獲取地圖頂部的緯度值.
                3. 使用上述 lat 和 long 作為時區創建 LatLng.
                4. 將此 LatLng 轉換為 Point,然后使用 x,y 從該點定位 div 元素.

                我在頁面第一次渲染和正文調整大小時執行邏輯.但是,如果我更改瀏覽器窗口的大小,時鐘的位置會不正確.

                有什么建議嗎?

                解決方案

                要回答OP的精確問題,即在調整瀏覽器窗口大小時如何重新定位時鐘(因此地圖容器尺寸可能已經改變),可能應該只需重新計算地圖

                現場演示:http://plnkr.co/edit/V2pvcva5S9OZ2N7LlI8r?p=preview

                I have tried this couple of ways but have not been able to get it working. I want to place clocks at the top of the map within multiple timezones. I have a the javascript to create the clock and I place the clock in a div element.

                Here is what I tried:

                1. Create a Point with 0,0 coordinates.
                2. From this point get the latitude value for the top of the map using containerPointToLatLng.
                3. Create LatLng using the above lat and long for the timezone.
                4. Converted this LatLng to Point and then positioning the div element with the x,y from this point.

                I execute the logic both when the page is first rendered and then on body resize. However, if I change the size of the browser window, the clock does not position correctly.

                Any suggestions?

                解決方案

                To answer OP's precise issue, i.e. how to re-position the clock when the browser window is resized (hence map container dimensions may have changed), one should probably just re-compute the clock position on map's "resize" event.

                However, it is not clear whether OP placed the clock as a child of the map container, or somewhere else on the page DOM tree.

                It is probably much easier to place it as a child of the map, so that its position is always relative to the map container.

                What OP originally asked?

                If I understand correctly the original desired result, the OP would like to overlay a clock (or whatever information) on top of a particular geographical position (Toronto city in that case [UTC -5], according to comments).

                However, the information container should not lay at a basemap fixed position, i.e. not at a precise geographic coordinated point (like a marker or a popup would), but at the top of the map container, similarly to a Control (hence iH8's original answer).

                Except that it should not be totally fixed within the map container, but horizontally move with the city (or whatever specified geographical coordinates). Hence OP's comment to iH8's answer.

                Therefore it sounds like something similar to that site, except with an interactive (navigate-able) map and the "UTC-5" header replaced by a clock (or whatever information, hence an HTML container should do it) and horizontally following Toronto.

                Put differently, the clock should sit at a particular vertical line, i.e. longitude / meridian.

                Unfortunately, even 2 years and a half after the question is posted, there is still no Leaflet plugin that provides such functionality (at least within Leaflet plugins page).

                Extending the use case to highly zoomed-in map…

                That being said, and given the fact that the user may be able to zoom highly into the city (OP did not specify the maximum zoom level), it might not be a very good user experience having that clock horizontally follow a precise longitude: for example, it could track Toronto centroid / city hall / whatever particular place, and when user is zoomed-in at another city district, the clock is no longer visible, whereas he/she is still viewing a part of Toronto city…

                To extend that use case, the clock should very probably be visible in whatever area it applies, i.e. as soon as the map view port intersects the associated time zone.

                Extending the use case to highly zoomed-out map…

                Another point not detailed by OP, is what to do when places of different time zones are visible in the map view port? In the above mentioned site, we have one header per visible time zone, which seems the most complete information we can get.

                But since Leaflet allows to zoom out down to level 0, where the entire world (i.e. essentially 24 time zones / actually 39 according to Wikipedia, not including potential effect of Daylight Saving Time - DST) is represented with a 256 pixels width, there is little room to fit all these clocks, if each one must be vertically aligned with its associated time zone.

                For now let's assume we do not care if clocks overlap.

                Even more custom case…

                But OP may have wished to display the clock only for particular places, not for the entire world. OP did not even say that clocks would be different (we could have clocks for cities in the same time zone, even though it could be more interesting to have these clocks sit next to their city - even on par with their latitude, so that it is easier to spot which city the clock is associated to, like in the case of 2 cities on the same meridian; but in that case, a marker with L.divIcon would be enough).

                Hence a custom case would be not to consider official time zones, but developer's specified areas.

                So we forget about the latitude and try to align a clock vertically above the area, as long as it intersects the map view port.

                Describing a generic solution

                Therefore it sounds like a generic solution would be to enable the application developer to specify an array of HTML Elements, each one associated with a range of longitudes (could also be an area / polygon).

                The time zones use case would then be a particular case where the specified areas are simply those from the time zones.

                Then, each Element should be visible if and only if its associated area intersects the view port (therefore we introduce a possibility to hide it when the latitude range is out of view).

                As for positioning, let's choose:

                • By the top of the map container (similar to a Control), as mentioned by OP.
                • Horizontally centered within the intersection of the view port and of the associated area.

                HTML:

                <div id="map"></div>
                
                <div id="clockToronto" class="clock leaflet-control">Clock here for Toronto</div>
                <div id="clockBurlington" class="clock leaflet-control">Clock here for Burlington</div>
                

                CSS:

                .clock {
                  width: 150px;
                  text-align: center;
                  position: absolute;
                  border: 1px solid black;
                }
                
                #clockToronto {
                  background-color: yellow;
                }
                
                #clockBurlington {
                  background-color: orange;
                }
                

                JavaScript:

                var map = L.map("map").setView([43.7, -79.4], 10);
                
                // Application specific.
                var clockTorontoElement = L.DomUtil.get("clockToronto"),
                    clockBurlingtonElement = L.DomUtil.get("clockBurlington"),
                    zones = [
                      {
                        element: clockTorontoElement, // Using the HTML Element for now.
                        width: parseInt(window.getComputedStyle(clockTorontoElement, null).getPropertyValue("width"), 10),
                        area: L.latLngBounds([43.58, -79.64], [43.86, -79.10]) // Using L.latLngBounds for now.
                      },
                      {
                        element: clockBurlingtonElement, // Using the HTML Element for now.
                        width: parseInt(window.getComputedStyle(clockBurlingtonElement, null).getPropertyValue("width"), 10),
                        area: L.latLngBounds([43.28, -79.96], [43.48, -79.71]) // Using L.latLngBounds for now.
                      }
                    ];
                
                // Initialization
                var controlsContainer = map._container.getElementsByClassName("leaflet-control-container")[0],
                    firstCorner = controlsContainer.firstChild,
                    mapContainerWidth;
                
                map.on("resize", setMapContainerWidth);
                setMapContainerWidth();
                
                // Applying the zones.
                for (var i = 0; i < zones.length; i += 1) {
                  setZone(zones[i]);
                }
                
                function setZone(zoneData) {
                  // Visualize the area.
                  L.rectangle(zoneData.area).addTo(map);
                  console.log("width: " + zoneData.width);
                
                  controlsContainer.insertBefore(zoneData.element, firstCorner);
                  map.on("move resize", function () {
                    updateZone(zoneData);
                  });
                  updateZone(zoneData);
                }
                
                function updateZone(zoneData) {
                  var mapBounds = map.getBounds(),
                      zoneArea = zoneData.area,
                      style = zoneData.element.style;
                
                  if (mapBounds.intersects(zoneArea)) {
                    style.display = "block";
                
                    var hcenterLng = getIntersectionHorizontalCenter(mapBounds, zoneArea),
                        hcenter = isNaN(hcenterLng) ? 0 : map.latLngToContainerPoint([0, hcenterLng]).x;
                
                    // Update Element position.
                    // Could be refined to keep the entire Element visible, rather than cropping it.
                    style.left = (hcenter - (zoneData.width / 2)) + "px";
                  } else {
                    style.display = "none";
                  }
                }
                
                function getIntersectionHorizontalCenter(bounds1, bounds2) {
                  var west1 = bounds1.getWest(),
                      west2 = bounds2.getWest(),
                      westIn = west1 < west2 ? west2 : west1,
                      east1 = bounds1.getEast(),
                      east2 = bounds2.getEast(),
                      eastIn = east1 < east2 ? east1 : east2;
                
                  return (westIn + eastIn) / 2;
                }
                
                function setMapContainerWidth() {
                  mapContainerWidth = map.getSize().x;
                }
                

                Live demo: http://plnkr.co/edit/V2pvcva5S9OZ2N7LlI8r?p=preview

                這篇關于如何使用傳單 js 在地圖上精確放置 div 元素?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                Trigger click on leaflet marker(觸發點擊傳單標記)
                How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                <legend id='HLNsZ'><style id='HLNsZ'><dir id='HLNsZ'><q id='HLNsZ'></q></dir></style></legend>
                  1. <i id='HLNsZ'><tr id='HLNsZ'><dt id='HLNsZ'><q id='HLNsZ'><span id='HLNsZ'><b id='HLNsZ'><form id='HLNsZ'><ins id='HLNsZ'></ins><ul id='HLNsZ'></ul><sub id='HLNsZ'></sub></form><legend id='HLNsZ'></legend><bdo id='HLNsZ'><pre id='HLNsZ'><center id='HLNsZ'></center></pre></bdo></b><th id='HLNsZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HLNsZ'><tfoot id='HLNsZ'></tfoot><dl id='HLNsZ'><fieldset id='HLNsZ'></fieldset></dl></div>

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

                      • <tfoot id='HLNsZ'></tfoot>
                        • <small id='HLNsZ'></small><noframes id='HLNsZ'>

                            <tbody id='HLNsZ'></tbody>
                          主站蜘蛛池模板: 久久国产精品精品国产色婷婷 | 中文字幕高清av | 日韩免费在线观看视频 | 先锋资源站 | 狠狠婷婷综合久久久久久妖精 | 国产伦精品一区二区三区在线 | 国产精品一区二区三区在线 | 国产成人在线一区 | www.操.com| 欧美日韩中文字幕在线 | 91高清免费观看 | 亚洲性网| 久久高潮 | 国产一级片在线观看视频 | 日韩欧美精品一区 | 亚洲视频欧美视频 | 欧美成人hd| 少妇精品亚洲一区二区成人 | 中文字幕日韩一区二区 | 免费观看黄色片视频 | 日产精品久久久一区二区福利 | h在线看| 成人黄色电影免费 | 最新av在线网址 | 日韩 欧美 综合 | 97色免费视频 | 国产在线视频一区二区 | 国产一级成人 | 日韩在线精品视频 | 手机看片在线播放 | aa级毛片毛片免费观看久 | 男女爱爱福利视频 | 欧美aaa一级片 | 国产视频三级 | 日韩欧美亚洲 | 久草视频在线播放 | 久草院线 | 欧美一区二区三区久久精品视 | 91看片网站| 日本精品免费在线观看 | 欧美综合久久久 |