Adding Points

You can add points to an existing GeoJSON layer using the "AddPoint()" function. The parameters are X,Y values for the coordinate. After the points have been added, you can add attributes and then values for the attributes based in indexes to the features in the layer. Below is a code sample from the California History example.

var Layer_Cities=new CMLayerGeoJSON();

Layer_Cities.SetProjector(TheProjector); // project the data to the same spatial reference as the map

Layer_Cities.SetName("Cities");
Layer_Cities.SetHTMLAttribute("name");

// add the coordinates

Layer_Cities.AddPoint(-121.941542,37.349217);
Layer_Cities.AddPoint(-123.243619,38.514080);

// add the attributes, for GeoJSON, this must be done after the points are added

Layer_Cities.AddAttributeHeading("name","default");
Layer_Cities.SetAttributeCell("name",0,"Mission Santa Clara");
Layer_Cities.SetAttributeCell("name",1,"Fort Ross");

Layer_Cities.SetFeatureIconImage(0,"Images/ChurchIcon.png",-17,-17);
Layer_Cities.SetFeatureIconImage(1,"Images/Historic.png",-17,-17);

TheCanvasMap.AddLayer(Layer_Cities);

The attributes contain the content that will appear in the title for the info box. Note that you can also use the "SetFeatureProperty()" function to change the icon for each point.