Projet

Général

Profil

Révision a3184cec

Ajouté par Jocelyn Delande il y a plus de 10 ans

PREFIXXX

Voir les différences:

js/utils_osm.js
16 16
    } else zcontrol = new OpenLayers.Control.Zoom();
17 17

  
18 18
    var map = new OpenLayers.Map({
19
	div: "map",
20
        zoom: typeof zoom == 'undefined' ? 10:zoom,
19
	    div: "map",
20
	    theme: null,
21
	    zoom: typeof zoom == 'undefined' ? 10:zoom,
21 22
	controls:[zcontrol,
22 23
		  new OpenLayers.Control.KeyboardDefaults(),
23 24
		  new OpenLayers.Control.Navigation()],
24 25
    });
25

  
26
	
27
	
26 28
    if (typeof scale_line != 'undefined' && scale_line == true) {
27 29
	map.addControl(new OpenLayers.Control.ScaleLine({bottomOutUnits: ''}));
28 30
    }
31
	map.celutz_addnew = false;
29 32

  
30 33
    if (typeof base_layers != 'undefined') {
31 34
	var layers = new OpenLayers.Control.LayerSwitcher();
......
61 64
		map.events.unregister("click", map, show_pos);
62 65
	    }
63 66
	}
67
	    
68
	    
69
    var bt_pano = mk_new_pano_button(map);
64 70
	var panel = new OpenLayers.Control.Panel({
65
	    div: document.getElementById("panel")
66
	});
71
		div: document.getElementById("panel"),
72
    	default: bt_pano,
73
        createControlMarkup: function(control) {
74
            var button = document.createElement('button'),
75
                iconSpan = document.createElement('span'),
76
                textSpan = document.createElement('span');
77
            iconSpan.innerHTML = ' ';
78
            button.appendChild(iconSpan);
79
            if (control.text) {
80
                textSpan.innerHTML = control.text;
81
            }
82
            button.appendChild(textSpan);
83
            return button;
84
        }
85
    });
67 86

  
68 87
	function formatLonlats(lonLat) {
69 88
	    lonLat.transform(map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
......
78 97
	    formatOutput: formatLonlats
79 98
	}));
80 99

  
81
	var history = new OpenLayers.Control.NavigationHistory();
100
    var history = new OpenLayers.Control.NavigationHistory({
101
	    previousOptions: {
102
		    title: "Go to previous map position",
103
		    text: "Préc."
104
	    },
105
	    nextOptions: {
106
		    title: "Go to next map position",
107
		    text: "Suiv."
108
	    },
109
    });
110
	    
82 111
	map.addControl(history);
83
	panel.addControls([history.next, history.previous]);
112
	    panel.addControls([bt_pano, history.next, history.previous]);
84 113
	map.addControl(panel);
85 114

  
86 115
	document.getElementById("clic_pos").onchange = set_pos;
......
315 344
	
316 345
	map.addControl(selectControl);
317 346
	selectControl.activate();
347
}
318 348

  
349

  
350
function mk_new_pano_button(map) {
351
	var btn = new OpenLayers.Control.Button({
352
		displayClass: 'olControlBtnNewPano',
353
		title: "Ajouter un nouveau panorama",
354
		text: "Photo",
355
		id: 'btn-new-pano',
356
		autoActivate: true,
357
		trigger: function() {start_add_new_pano(map)},
358
	});	
359
	return btn;
360
}
361

  
362

  
363
function add_pano_click_handler(callback) {
364
	var ctrlClass = OpenLayers.Class(OpenLayers.Control, {                
365
		defaultHandlerOptions: {
366
		    'single': false,
367
		    'double': true,
368
		    'pixelTolerance': 0,
369
		    'stopSingle': false,
370
		    'stopDouble': false
371
		},
372

  
373
		initialize: function(options)
374
		{
375
		    this.handlerOptions = OpenLayers.Util.extend(
376
		        {}, this.defaultHandlerOptions
377
		    );
378
		    
379
		    OpenLayers.Control.prototype.initialize.apply(this, arguments);
380
		    
381
		    this.handler = new OpenLayers.Handler.Click(
382
		        this, {
383
		            'click': callback
384
		        }, this.handlerOptions
385
		    );
386
		},
387
	});
388
	
389
	var control = new ctrlClass({
390
		        handlerOptions: {
391
		            "single": true,
392
		            "double": false
393
		        },
394
		autoActivate: true});
395
	
396
	return control;
397
}
398

  
399
function start_add_new_pano(map) {
400
	map.celutz_addnew = true;
401
	alert("cliquer sur un point de la carte pour choisir l'emplacement");
402
	document.body.style.cursor = 'crosshair';
403
	
404
	var control = add_pano_click_handler(function(evt) {
405
		var coord = map.getLonLatFromPixel(evt.xy);
406
		coord.transform(new OpenLayers.Projection("EPSG:900913"), 
407
		                new OpenLayers.Projection("EPSG:4326"));
408
		window.location = 'envoyer.php?lat='+coord.lat+'&lon='+coord.lon;
409
	});
410
	map.addControl(control);
319 411
}
320 412

  

Formats disponibles : Unified diff