1. A method of performing simultaneous localization and mapping (SLAM) optimization, the method comprising: receiving, by one or more processors, traces collected by multiple portable devices moving within a geographic area that includes an indoor region, each of the traces including measurements of wireless signals sources at different times by a same device; determining, for each of a plurality of cells in the geographic area, respective probabilities of moving in various directions relative to the cell, the plurality of cells defining a motion map for the geographic area; and generating, by the one or more processors, location estimates for the portable devices and the signal sources using graph-based SLAM optimization of the location estimates, including, for at least some of the location estimates: determining to which of the plurality of cells of the motion map the location estimate corresponds, and applying the measurements of wireless signals sources and the set of probabilities of the cells as a first constraint and a second constraint, respectively, in the graph-based SLAM optimization.