Projet

Général

Profil

Révision e1acd4a1

Ajouté par Jocelyn Dealande il y a plus de 9 ans

Can add a panorama from the map.

Voir les différences:

js/utils_osm.js
341 341
				feature.popup.destroy();
342 342
				feature.popup = null;
343 343
			}});
344
	
344

  
345 345
	map.addControl(selectControl);
346 346
	selectControl.activate();
347
}
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
		    );
347 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);
348 411
}
349 412

  
350 413

  

Formats disponibles : Unified diff