//PHP REST map route call
  //https://maps.alk.com/PCMDoc/MapRoute
    if(isset($_POST['submit'])){

        $apiKey = isset($_POST['apiKey']) ? $_POST['apiKey'] : '';
        $url = "http://pcmiler.alk.com/apis/rest/v1.0/Service.svc/mapRoutes?dataset=Current";
        $data = '{
      "Map":{
         "Viewport":{
          "Center":null,
          "ScreenCenter":null,
          "ZoomRadius":0,
         },
         "Projection":0,
         "Style":0,
         "Width":1345,
         "Height":960,
         "Drawers":[
         0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28
            ],
         "LegendDrawer":[
          {
             "Type":0,
             "DrawOnMap":true
          }
         ],
         "PinDrawer":{      
          "DrawOnMap":true,
          "Pins":[{
            "ID":1,
            "Point":{
              "Lat":"34.480831",
              "Lon":"-119.698190"
            },
            "Image":"ltruck_r",
            "Label":"truck1"
          },
          {
            "ID":2,
            "Point":{
              "Lat":"33.519977",
              "Lon":"-112.074037"
            },
            "Image":"ltruck_g",        
            "Label":"truck2"
          }
          ]
        },
        },
      "Routes":[
         {
          "RouteId":null,
          "Stops":[
             {
              "Address":{
               "StreetAddress":null,
               "City":"New York",
               "State":"NY",
               "Zip":"12345",
               "County":null,
               "Country":null,
               "SPLC":null,
               "CountryPostalFilter":0,
               "AbbreviationFormat":0
              },
             
              "Region":4,
              "IsViaPoint":false
             },
             {
              "Address":{
               "StreetAddress":null,
               "City":"Seattle",
               "State":"WA",
               "Zip":"",
               "County":null,
               "Country":null,
               "SPLC":null,
               "CountryPostalFilter":0,
               "AbbreviationFormat":0
              },
             
              "Region":4,
              "IsViaPoint":false
             }
          ],
          "Options":{             
             "BordersOpen":false,
             "ClassOverrides":1,                    
             "FerryDiscourage":true,           
             "HazMatType":0,
             "HighwayOnly":true,
             "OverrideRestrict":false,
             "RouteOptimization":0,
             "RoutingType":1,
             "TollDiscourage":false,
             "TruckCfg": {
            "Units": 0,
            "Height": "13\'6\"",
            "Length": "53\'",
            "Width": "102\"",
            "Weight": "80000",
            "Axles": 6,
            "LCV": false
          },             
             "TruckStyle":4,
             "VehicleType":0
          }        
         }
        ]
      }  ';
        
        $headers = "Authorization:  $apiKey  " . "\r\n";
       
        $headers = $headers . "Content-Type: application/json";
        do_post_request($url, $data, $headers);
    }


        
    function do_post_request($url, $data, $headers = null) {
            $params = array('http' => array(
                    'method' => 'POST',
                    'content' => $data
            ));


            if ($headers !== null) {
                $params['http']['header'] = $headers;
            }
            $ctx = stream_context_create($params);
            $fp = @fopen($url, 'rb', false, $ctx);
            if (!$fp) {
                throw new Exception("Problem with $url, $php_errormsg");
            }
            $response = @stream_get_contents($fp);
            if ($response === false) {
                throw new Exception("Problem reading data from $url, $php_errormsg");
            }

           echo "<img src='data:image/png;base64,".base64_encode($response)."' />";
            return $response;
        }



This sample may use features that are only available in our Premium WebServices. Please refer to our Features page to confirm what feature level you currently subscribe to.