Ask a questionAsk a question
 

AnswerStart map in OS Mode

  • Friday, August 21, 2009 7:36 PMAndrewM Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi, I would like to set a map to start in the Ordnance Survey mode when appropriate, but I can only see options to set the other map modes. Can it be done or is it to be added?
    Andrew

Answers

  • Sunday, August 23, 2009 10:45 AMRossko57 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I got this bit of code from the old API forum -


    var OSmaptype = 904 ;     // code for OS, may change
    var prefs = MMDataResolver.getDataPreferences(mapType);
    var newprefs = [OSmaptype]; // put OS map on top
     for( var i = 0 ; i < prefs.length ; ++i )  // scan maptypes:
     {
         if (prefs[i] != OSmaptype)
            { newprefs.push(prefs[i]) }
      }
      MMDataResolver.setDataPreferences( mapType, newprefs );

    The 904 is something of a magic number; to find it out, you can use www.multimaps.com switch to the 'basic maps', get an OS map view and then examine the url to see " ...&mapData=904"

    cheers, Ross K
    • Marked As Answer byAndrewM Monday, August 24, 2009 11:38 AM
    •  

All Replies

  • Sunday, August 23, 2009 10:45 AMRossko57 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I got this bit of code from the old API forum -


    var OSmaptype = 904 ;     // code for OS, may change
    var prefs = MMDataResolver.getDataPreferences(mapType);
    var newprefs = [OSmaptype]; // put OS map on top
     for( var i = 0 ; i < prefs.length ; ++i )  // scan maptypes:
     {
         if (prefs[i] != OSmaptype)
            { newprefs.push(prefs[i]) }
      }
      MMDataResolver.setDataPreferences( mapType, newprefs );

    The 904 is something of a magic number; to find it out, you can use www.multimaps.com switch to the 'basic maps', get an OS map view and then examine the url to see " ...&mapData=904"

    cheers, Ross K
    • Marked As Answer byAndrewM Monday, August 24, 2009 11:38 AM
    •  
  • Monday, August 24, 2009 11:36 AMAndrewM Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ok that works, thanks (seems to just add "dp=os" now in the url).

    One issue though - when zoomed right in the os map is a different type and gets turned off with this method (reverts to default style).
  • Tuesday, October 06, 2009 2:56 PMJohn-SheridanMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi
    Referring to the information and posts about "magic numbers", as map data is routinely updated, the map data values (the magic numbers) may also change at any time, therefore we do not recommend any implementations make use of specific map data values.  To implement different map data we recommend implementing along the lines of the Map Data Preference example at http://clients.multimap.com/share/documentation/openapi/1.2/demos/dataprefs.htm .
    Thanks, John.