[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
www.undertowsoftware.com • View topic - Mapmode Questions

Mapmode Questions

A forum made available for users of the MapPro OCX SDK to exchange ideas, ask each other questions, etc.

Mapmode Questions

Postby mAlagi » Fri Mar 30, 2012 11:12 am

I think the availability of the various mapmodes is really a good feature, but it would be nice if there were some good examples of when/how to use each map mode. Plus, I think there might a "confusing" element to the way they work. For example, in the default mode, the mouse-clicks are handled by the program to recenter, zoom out, etc. So, if I want to do something when the user clicks the mouse button, I can do it, but I have to know before hand to set the program in mdUser, otherwise I process the mouse_click, but so does the OCX, so the user clicks to select something, the item is selected but the map is also re-centered.

I hope I am making sense. I am kind of frustrated right now.

Anyway, if anyone has any code samples or useful hints, I would appreciate it.
"640K ought to be enough for anybody." - Bill Gates, 1981
User avatar
mAlagi
Active User
Active User
 
Posts: 28
Joined: Fri Aug 12, 2011 11:09 am

Re: Mapmode Questions

Postby UShadow » Mon Apr 02, 2012 10:17 am

mAlagi wrote:I think the availability of the various mapmodes is really a good feature, but it would be nice if there were some good examples of when/how to use each map mode. Plus, I think there might a "confusing" element to the way they work. For example, in the default mode, the mouse-clicks are handled by the program to recenter, zoom out, etc. So, if I want to do something when the user clicks the mouse button, I can do it, but I have to know before hand to set the program in mdUser, otherwise I process the mouse_click, but so does the OCX, so the user clicks to select something, the item is selected but the map is also re-centered.

I hope I am making sense. I am kind of frustrated right now.

Anyway, if anyone has any code samples or useful hints, I would appreciate it.

Malagi, I can understand your frustration. Been there many times :-( Like everything else, what you do with the mapmode is really up to you and how much code you are willing to write. You could, for example, set the mode to mdUser and then handle ALL mouse clicks yourself, including simulating the zoom-out (right-click) and add your own zoom rectangle. That may require the most code, but would probably be the best solution.

If you provide some more detail as to what it is you are trying to do, someone here may be able to come up with a better suggestion.
Imagination is greater than detail - Albert Einstein
User avatar
UShadow
Frequent User
Frequent User
 
Posts: 61
Joined: Fri May 28, 2010 11:49 am

Re: Mapmode Questions

Postby mAlagi » Tue Apr 03, 2012 8:31 am

Thanks, Ushadow.

What I want to do is very simple. I want to be able to click on a spot on the map and then decide whether I want to handle that click myself, or allow it to go through and have the default behavior for it. It appears to be a really simple task, but I'm having all sorts of difficulties with it.
"640K ought to be enough for anybody." - Bill Gates, 1981
User avatar
mAlagi
Active User
Active User
 
Posts: 28
Joined: Fri Aug 12, 2011 11:09 am

Re: Mapmode Questions

Postby jodax3 » Wed Apr 04, 2012 10:09 am

Its a little complicated , but only takes a few lines of code;

When in mdUser mode, the automatic zoom/pan behaviour is disabled, but the mousedown/mouseup/mousemove events are still enabled. Mappro exposes several methods that allow you to initiate the same automatic behaviour,i.e. GotoPoint() (Left Click Action), ZoomWindow() (which uses integer mouse coordinates passed in the mouse events) and ZoomOut (Right Click action).

Here's some code (Delphi), Hope its relatively clear.

var ax,ay:integer;
flag:boolean; // initialize to false

procedure TForm1.MapPro1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if mappro1.mapmode=mduser then
begin
// -- Check the mouse position and decide if you want to suppress the zoom/pan functions
//-- If Yes which case, don't set the "flag" to true.
//----
flag:=true;
ax:=x;
ay:=y;
end;
end;

procedure TForm1.MapPro1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var b:tbrush; hb:hbrush;
begin
if flag then // only draw the rectangle if the flag is true,i.e. the mouse button is down
begin
// Use whatever you think would make a good highlight rectangle

// ... DRaw a rectangle from x,y to ax,ay to show zooming area
b:=tbrush.create;
try
b.style:=bsclear; // a transparent brush
dc:=getdc(mappro1.handle);
hb:=selectobject(dc,b.handle);
Rectangle(dc,x,y,ax,ay); // note you should select a clear brush in ,
selectobject(dc,hb);
releasedc(mappro1.handle,dc); // free your device context
finally

b.free; // free up your brush
end;
end;
end;

procedure TForm1.MapPro1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if flag then
begin
flag:=false;// reset the recorded state of the mouse
// check the amount of movement of the mouse from the initial click
if (abs(ax-x)>16) or (abs(ay-y)>16) then // a test to determine if a zoomwindow or click recenter
begin
mappro1.zoomwindow(ax,ay,x,y); // use the mappro1 pixel coordinates
end else
begin
mappro1.gotopoint(mappro1.xcord,mappro1.ycord);// use the current lon/lat of the mouse
end;
end;
end;
User avatar
jodax3
New User
New User
 
Posts: 6
Joined: Mon Dec 19, 2011 7:00 pm

Re: Mapmode Questions

Postby mAlagi » Wed Apr 04, 2012 3:27 pm

Thank you very very much, jodax3. I have to convert it for my C#, but it's exactly what I was looking for. I have also sent you a private message on this board...
"640K ought to be enough for anybody." - Bill Gates, 1981
User avatar
mAlagi
Active User
Active User
 
Posts: 28
Joined: Fri Aug 12, 2011 11:09 am

Re: Mapmode Questions

Postby LarryWilton » Thu Apr 05, 2012 12:04 pm

Excellent code jodax3, thanks! That's exactly what *I* was looking for as well. Now that I see it, it makes sense :-)

One question, why Delphi? There are such better environments these days.
User avatar
LarryWilton
Active User
Active User
 
Posts: 26
Joined: Thu Aug 25, 2011 9:23 am

Re: Mapmode Questions

Postby jimwelch » Thu Apr 05, 2012 2:29 pm

LarryWilton wrote:Excellent code jodax3, thanks! That's exactly what *I* was looking for as well. Now that I see it, it makes sense :-)

One question, why Delphi? There are such better environments these days.

What's wrong with Delphi, Larry?

I hope we don't start another "My Development Language is Better Than Yours" war, like the many that have been going on, on-line for the past couple of decades. Delphi may not be my favorite, or yours, but I think most (all ?) development languages nowadays provide the level of complexity and sophistication needed and expected by developers. It really becomes an issue of what you like and what you are most familiar with!

I know that many "holier-than-thou" developers used to laugh at VB, but I also know that tens/hundreds of thousands of complex applications were indeed developed in VB. (Not singling out VB - just using it as an example).

A good developer in-depth knowledge of "whatever" language they are using can make it do pretty much what they want!

I just thought I'd get this off my chest :-)
User avatar
jimwelch
Active User
Active User
 
Posts: 20
Joined: Mon Feb 06, 2012 10:55 pm


Return to MapPro OCX

Who is online

Users browsing this forum: No registered users and 2 guests

cron