Map menu offset

Adds a map to the forum where users can enter her position.
Post Reply
EntonoX
Benutzer
Benutzer
Posts: 3
Joined: 14. Jul 2016 11:18

Map menu offset

Post by EntonoX » 14. Jul 2016 12:26

Hello,

Extention is working good :) Only problem is that when i left click on the map the menu has a big offset. for example when i left click in the upper left corner the menu shows in the middle of the map.

I traced the code and e.pageX and e.pageY code is used to determine the position of the menu. I am using 'We_universal' theme together with phpBB 3.1.9.

Thanks in advance!

EntonoX
Benutzer
Benutzer
Posts: 3
Joined: 14. Jul 2016 11:18

Re: Map menu offset

Post by EntonoX » 18. Jul 2016 13:31

Well seems the forum is deserted, but for future use i'll post the solution to this problem below

Inside the

Code: Select all

ext/tas2580/usermap/styles/all/template/usermap.js
file you change this;

Code: Select all

usermap.display_menu=function(e, lon, lat) {
	usermap.hide_menu(true);
	//$('#map_menu').css({'top':e.pageY,'left':e.pageX,'display':'block'});
	
	var x = e.pageX - $('#map').offset().left;		//Substract page offset minus MAP div offset
	var y = e.pageY - $('#map').offset().top;		//Substract page offset minus MAP div offset
	
	$('#map_menu').css({'top':y+105,'left':x+30,'display':'block'});		//Add 105 and 30 for final adjusting
	$('#map_menu').find('a').each(function() {
		var href = $(this).attr('href');
		$(this).attr('href', href.replace('LONLAT', 'lon='+lon+'&lat='+lat));
	});
};
This will position the menu right and below of the crosshair. With the original code the position of the mouse relative to the page is received. Then again this offset is used for the menu. This way you get a menu which has a huge offset and is not really usable. :?

I solved this by substracting the offset of the page with the offset of the MAP div. This way the result is the actual position of the crosshair inside the MAP div. The final 105 and 30 added to the CSS ar for fine tuning and perfectly aligning the menu right and below the crosshair :o

BryceWell
Benutzer
Benutzer
Posts: 1
Joined: 22. Aug 2017 12:59

Re: Map menu offset

Post by BryceWell » 29. Aug 2017 11:15

Thanks for the fix Entono.

Post Reply

Social Media

       

Who is online

Users browsing this forum: No registered users and 1 guest