I want to run the code only once in a template.food. I have a sheet map and a place-control plugin is integrated, it still works quite well, but it seems that the rendered template goes back again and again to find the user on the map. The marker resets every few seconds. I want to start it once.
var map, mapInit; Map = zero zero; MapInit = function (element) {map = L.mapbox.map (element, 'example.map-20v6611k'). Setview (New L. Latang (52.02312,13.02627), 11); L.control.locate ({drawCircle: true, position: 'top'}). AddTo (map); } Template.map.rendered = function () {$ (window) Resize (function () {var h = $ (window) .height (); $ mc = $ ('# map'); $ mc.css ('height', h);}). Resize (); If (! This.rendered) {mapInit ('map'); This.rendered = true; You may want to save the map's DOM elements in global or app variables. (Here, map
), and rejoin them in the DOM: var map; ... var mapDomElement = $ ('# map'); If (map.domainments) {mapDomElement.replaceWith (Map.domElements); } Else {Map.mapObject = L.mapbox.map (...) // Quick Map here map.Diamlands = map transmitted; }
Note Again high re-sequence: You do not have to do this. Use the CSS Flex box model to maximize the map height:
& lt; Div style = "display: flex; flex-flow: column; min-height: 100%" & gt; & Lt; Div id = "map" style = "flex: 1" & gt; & Lt; / Div & gt; & Lt; Div & gt; ... map control here & lt; / Div & gt; & Lt; / Div & gt;
See on the flex model "The stuff goes here" div is your map.
Comments
Post a Comment