.join()
An join method is used to combine rows from two or more tables, based on a common field between them. Syntax .join(tableName: string) Example
  1. var county = {
  2. query: {
  3. table: { name: 'census/Counties' },
  4. select: { type: 'geo.poly' },
  5. join: {
  6. method: "PointInPolyJoin",
  7. table: "hms/hotels"
  8. }
  9. },
Demo
  1. <html>
  2. <head>
  3. <script type='text/javascript' src='http://my.maplarge.com/js'></script>
  4. <script type='text/javascript'>
  5. ml.onload(function () {
  6. var county = {
  7. query: {
  8. table: { name: 'census/Counties' },
  9. select: { type: 'geo.poly' },
  10. join: {
  11. method: "PointInPolyJoin",
  12. table: "hms/hotels"
  13. }
  14. },
  15. style: {
  16. method: 'interval',
  17. shadeBy: "hms/hotels.LowRate.avg", //count, sum, avg
  18. colors: [
  19. { min: 'LightBlue-64', max: 'Blue-128' },
  20. { min: 'Blue-128', max: 'Red-128' }
  21. ],
  22. ranges: [
  23. { min: 0, max: 75 },
  24. { min: 75, max: 150 }
  25. ]
  26. },
  27. onHover: function (data,layer) {
  28. return "Avg. Low Rate: $" + Math.round(data.subTotals.LowRate.avg);
  29. },
  30. //listing the hms/hotels table here is mandatory because we have two tables
  31. //.avg represents the average of the "LowRate" column points in this County
  32. hoverFields: ['hms/hotels.LowRate.avg'],
  33. onClick: 'debug'
  34. //when you click debug notice the shape data is under data.data
  35. //and how the point totals are under data.subTotals
  36. };
  37. //create a new div and add to document
  38. //you could also fetch the element by id
  39. var div=document.getElementById('pointpoly');
  40. var map = new ml.map(div, { lat: 36.967449, lng: -94.76806, z: 5 });
  41. var layer = new ml.layer(map, county);
  42. layer.show();
  43. });
  44. </script>
  45. </head>
  46. <body>
  47. <div id="pointpoly">
  48. </div>
  49. </body>
  50. </html>