Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

HTML, activeX and Javascript - Union method problem

This is a discussion on HTML, activeX and Javascript - Union method problem within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I'm developing a web application in php and I'm trying to control some aspects of the ActiveX component with ...

  1. #1
    mcjwb is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    7

    HTML, activeX and Javascript - Union method problem

    Hi,
    I'm developing a web application in php and I'm trying to control some aspects of the ActiveX component with Javascript.

    The problem I am having is with the Union method. I want to beable to display several pushpins on the map (which I can do) and then zoom out and center the map view so all pushpins can be seen on the current map view - precisely what the Union method promises to do.

    Here's my code:
    Code:
    var objLoc1 = map1.ActiveMap.FindPushPin(ar[0].rtu_id).Location;
    var objLoc2 = map1.ActiveMap.FindPushPin(ar[1].rtu_id).Location;
    map1.ActiveMap.Union(Array(objLoc1, objLoc2)).GoTo();
    It is very similar to the example on the MSDN VB Union method page, but my code throws the error:
    "The parameter is incorrect"

    I've tried defining the array before the union method and just using the array reference but that throws the same error.

    Any ideas?

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Your question saved me time I was just busy with some code to move some pushpins to a dataset for using the ZoomTo() method because I was unaware of the union method. So I tryed following to see if works:

    Code:
                Pushpin pp;
                int count = 10;
                double lon = 50;
    
                while (count-- > 0) {
                    lon += 0.5;
                    Location loc = MP.ActiveMap.GetLocation(lon, 4, 1);
                    pp = MP.ActiveMap.AddPushpin(loc, count.ToString());
                    pp.Symbol = 1;
                }
    
                Location[] aLoc = new Location[3];
                aLoc[0] = MP.ActiveMap.FindPushpin("1").Location;
                aLoc[1] = MP.ActiveMap.FindPushpin("2").Location;
                aLoc[2] = MP.ActiveMap.FindPushpin("3").Location;
    
                MP.ActiveMap.Union(aLoc).GoTo();
    And it does. Possible that your code trows an exception because one of the pushpins is not found ? Because I think it really needs this check.

  3. #3
    mcjwb is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    7
    I am fairly confident my pushpins are being found, objLoc1 and objLoc2 are both objects.

    Is your code Javascript? I don't recognise some of the format eg:
    Location[] aLoc = new Location[3];
    And it doesn't work for me

    If I alter your code so it works for me I get:
    Code:
                count = 10; 
                lon = 50; 
    
                while (count-- > 0) { 
                    lon += 0.5; 
                    Location loc = MP.ActiveMap.GetLocation(lon, 4, 1); 
                    pp = MP.ActiveMap.AddPushpin(loc, count.toString()); 
                    pp.Symbol = 1; 
                } 
    
                aLoc = new Array(3); 
                aLoc[0] = MP.ActiveMap.FindPushpin("1").Location; 
                aLoc[1] = MP.ActiveMap.FindPushpin("2").Location; 
                aLoc[2] = MP.ActiveMap.FindPushpin("3").Location; 
    
                MP.ActiveMap.Union(aLoc).GoTo();
    But this still throws the error "The parameter is incorrect".

    What are you developing on/in?

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    No the code example I posted is C#. This looks very mutch like JavaScript, so as you have done you only need very minor modifications to have it work for you, and yes the "strange" code from me is the New Array

    One more question. If I understeand you when you say "it works" and also "it trows the error", do I understeand it right that:

    - the GoTo() function _is_ working, eg the map zoom to the pushpins.
    - the very same Goto() function trows an exception with the "The parameter is incorrect" message.

    ??

  5. #5
    mcjwb is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    7
    Sorry I didn't make that very clear, I'll try again:

    The "The Parameter is incorrect" error is coming from the Union() Method. So the code fails at the Union() method so the GoTo() method is not called.

    (I've tried the GoTo() method on a different single location object and that works as intended.)

    I really can't see what I'm doing wrong, to the best of my knowledge both objLoc1 and objLoc2 (in my original code) are location objects. Then I simply put them into an array and use that array as the argument for the Union() method, which then results in the error message "The parameter is incorrect".

    Any ideas?

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I'm just guessing, but maybe calling convention ? Maybe JavaScript try to push the array on the stack, try to pass is explicitely by address. Dont know the syntax, probably something like:

    Code:
    MP.ActiveMap.Union(&aLoc).GoTo();
    (could be different of course)

  7. #7
    mcjwb is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    7
    Hi,

    I don't fully understand your last post, about calling conventions and "the stack", but will attempt a reply:

    I'm not sure that javascript has as complex a calling convention as C#. Objects and arrays are always passed by reference in javascript.

    Suffice to say, your suggested code syntax is not valid in javascript and I cannot find anything resembling what you are after.

    But, thanks for trying.


    Am I the only person trying to control the mappoint activeX object with Javascript??? Has no one come across this, or similar, problem before?

  8. #8
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    It is possible that you're one of the first people to try it. The EULA (and the physical practicalities of distribution) prohibit true Internet use of the MapPoint ActiveX control. Intranet use is viable, but I don't think many people have gone this route - a traditional application is easier and in many ways has advantages over the web-for-everything approach.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  9. #9
    mcjwb is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    7
    Richard,

    I don't recall the EULA mentioning the activeX control, though I suppose it probably wasn't worded as such. Could you elaborate
    prohibit true Internet use
    ?

    When you put it that way I guess not so many people would bother going down the html embeded activex control route. My web application can use several different types of mapping solution. I just thought the mappoint activex control would be a lot smoother, faster and nicer solution, being client side and all.

  10. #10
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    For Joe Public to use the MapPoint Active X control, then they must have MapPoint installed on their PC. If you are relying on that stage, then I think you're okay (although there are various caveats in the EULA about internet use - eg. a query application that queried a server-based MapPoint for images on demand is explicitly limited).
    [and this is why I say an Intranet should be okay: you or your sysadmin has already installed legal copies]

    How many users will have MapPoint already installed? I suspect not that many. So some people have talked about having a "download" on their site which downloads the control. This is impractical because of the large amount of attached data/etc. It is also prohibited, as it essentially software piracy.

    Similarly if you distribute your own application with an embedded control, you cannot distribute the control with your software - you have to demand your user installs it beforehand. (you might be able to get Microsoft to go in for a large licensing scheme, but that will up your costs a lot!)


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can I embed MapPoint ActiveX Ctrl in HTML with JScript/VBScr
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-16-2006, 04:01 AM
  2. Problem saving map to html
    By MarkStanley in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-22-2005, 03:24 PM
  3. PrintOut method with MapPoint ActiveX control?!!
    By TheJudge in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-13-2004, 06:35 PM
  4. Problem with the optermise method
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-14-2003, 10:06 AM
  5. problem with IMPORT-method
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-04-2003, 09:41 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36