From: Tom Hughes Date: Mon, 1 Aug 2011 08:09:24 +0000 (+0100) Subject: Don't create the map until after the div for it is made visible X-Git-Tag: live~6809 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0595255d5879de78a1f35e0fb8ab57ea89026694 Don't create the map until after the div for it is made visible --- diff --git a/app/views/diary_entry/edit.html.erb b/app/views/diary_entry/edit.html.erb index 160637b16..9e7d5bab8 100644 --- a/app/views/diary_entry/edit.html.erb +++ b/app/views/diary_entry/edit.html.erb @@ -55,17 +55,6 @@ OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>"); - function init() { - var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>); - var zoom = <%= zoom %>; - - var map = createMap("map"); - - setMapCenter(centre, zoom); - - map.events.register("click", map, setLocation); - } - function setLocation( e ) { closeMapPopup(); @@ -84,8 +73,15 @@ function openMap() { $("map").style.display = "block"; $("usemap").style.display = "none"; - } - window.onload = init; + var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>); + var zoom = <%= zoom %>; + + var map = createMap("map"); + + setMapCenter(centre, zoom); + + map.events.register("click", map, setLocation); + } // -->