Node fromSpot and toSpot not working for links

Seems like the links are connecting to any sides randomly. However, if I create a linkTemplate the fromSpot and toSpot works. But I need to use different linktemplate for different nodes. I have tried creating a new linkTemplateMap for different link types but don’t know how to use different linktempaltes in nodes. As nodes are already using nodetemplate by using category property.

myDiagram.nodeTemplate =
  $(go.Node, "Vertical", 
    { rotatable: false, 
      background: "#44CCFF", 
      deletable: false, 
      fromSpot: go.Spot.TopCenter, 
      toSpot: go.Spot.BottomCenter, 
      locationSpot: go.Spot.TopLeft,
      movable : false,
      canMove: false,
    }, 
   new go.Binding("angle").makeTwoWay(),
    $(go.Shape, "Rectangle", {
        toMaxLinks: 1,
        fromMaxLinks: 1,
        width: 75,
        height: 75,
        stroke: "black",
        strokeWidth: 1,
        portId: "",
        cursor: "pointer", 
        fromLinkable: true, fromLinkableSelfNode: false, fromLinkableDuplicates: false,
        toLinkable: true, toLinkableSelfNode: false, toLinkableDuplicates: false
    }, new go.Binding("fill", "color")),
    $(go.TextBlock, "Default text", { margin: 6, font: "bold 18px sans-serif"}, 
    new go.Binding("text", "name").makeTwoWay())
    );


 var nodeTopConnectionTemplate =
  $(go.Node, "Auto", 
    { rotatable: false, 
      background: "#44CCFF", 
      deletable: false, 
      fromSpot: go.Spot.TopCenter,
      toSpot: go.Spot.BottomCenter, 
      locationSpot: new go.Spot(0,0, 0, -20), 
      movable : false,
      canMove: false,
    }, 
   new go.Binding("location", "loc"),
    $(go.Shape, "Rectangle", {
        toMaxLinks: 1,
        fromMaxLinks: 1,
        width: 75,
        height: 75,
        stroke: "black",
        strokeWidth: 1,
        portId: "",
        cursor: "pointer", 
        fromLinkable: true, fromLinkableSelfNode: false, fromLinkableDuplicates: false,
        toLinkable: true, toLinkableSelfNode: false, toLinkableDuplicates: false
    }, new go.Binding("fill", "color")),
    $(go.TextBlock, "Default text", { margin: 6, font: "bold 18px sans-serif"}, 
    new go.Binding("text", "name").makeTwoWay())
    );

  var nodetemplmap = new go.Map();
  nodetemplmap.add("nodeTopConnectionTemplate", nodeTopConnectionTemplate);
  nodetemplmap.add("", myDiagram.nodeTemplate);

  myDiagram.nodeTemplateMap = nodetemplmap;

Normally one sets the from Spot and/or toSpot properties on the port(s) of the node, not on the link.

I think the problem in your case is that you did not set the spots on the port, the object that has portId set to a string.

The whole Node is a port only if no GraphObject in the node has portId set to a string.