[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] Optimizing MapOSMatic homepage load time

From: Thomas Petazzoni
Subject: [Maposmatic-dev] Optimizing MapOSMatic homepage load time
Date: Thu, 5 Nov 2009 23:20:15 +0100

Hello Étienne,

Since we added the slippy map on homepage, the load time
of the page has increased quite significantly since when loaded, it
automatically starts loading tiles from OSM servers. However, this is
useless since by default, the slippy map is not displayed.

Therefore, tonight, I've tried to keep the slippy map initialized,
until the user select the « Bounding Box » selection mode. This works
fine, except that the initial area displayed by the map is broken: for
some reason the lat/lon input boxes contain NaN (not a number) and the
slippy map shows a highly-zoomed area somewhere in the middle of France.

You'll find below the patch I've done to do this. Do you have any idea
of what's going wrong ?

Thanks a lot for your input!


diff --git a/www/maposmatic/ b/www/maposmatic/
index 0569c83..8e4742a 100644
--- a/www/maposmatic/
+++ b/www/maposmatic/
@@ -78,7 +78,7 @@ class AreaWidget(forms.TextInput):
 """ % (upper_left_lat, upper_left_lon, lower_right_lon, lower_right_lat)
         tpl += u"""<script type='text/javascript'><!--
 // -->
diff --git a/www/templates/maposmatic/index.html 
index b93bb59..046e420 100644
--- a/www/templates/maposmatic/index.html
+++ b/www/templates/maposmatic/index.html
@@ -32,9 +32,15 @@
 {% block extrajs %}
 String.prototype.startsWith = function(str) { return this.indexOf(str) === 0; }
+bboxinitialized = false;
 function area_selection_mode_switch(mode)
+  if (mode == 'bbox-mode' && bboxinitialized == false) {
+      bboxinitialized = true;
+      init();
+  }
   var arr = document.getElementById('mapform').getElementsByTagName('tr');
   for (i=0; i < arr.length; i++) {
     if (arr[i].className.startsWith('byadmin')) {

Thomas Petazzoni               
Promouvoir et défendre le Logiciel Libre
Logiciels Libres à Toulouse    

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]