Telogis.GeoBase.MapLayers.CircleFence |
MapLayers.CircleFence inherits from MapLayers.GeoFence.
A circular form of geofence, as described by a coordinate-pair center point and a distance radius in some fixed units.
// Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true });
Name | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MapLayers.CircleFence(config) | Arguments
|
Name | Description |
---|---|
contains (LatLon loc) | Determines whether a given point lies within the fence boundaries. JavaScript // Set the location we will use for the center of the fence var fenceCenter = new Telogis.GeoBase.LatLon(33.575131,-117.778007) map.setCenter(fenceCenter); var balloonText; // Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: fenceCenter, radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); // Create test locations var inside = new Telogis.GeoBase.LatLon(33.573818,-117.775948); var outside = new Telogis.GeoBase.LatLon(33.579922,-117.785417); // Test the 'outside' location against the circle fence if (myCircleFence.contains(outside)) { balloonText = 'I am within the fence'; } else { balloonText = 'I am outside the fence'; } // Put a pin on the map to make visualization easier var pinBob = new Telogis.GeoBase.MapLayers.ImageObject({ map: map, balloonConfig: {content: balloonText}, location: outside, src: 'images/pin-red.png' });
Boolean - True if MapLayers.CircleFence.contains.loc lies within the fence; false otherwise. |
getCenter () | Finds the coordinates of the center of the fence. JavaScript // Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); alert('Center of the CircleFence is '+myCircleFence.getCenter()); // Center of the CircleFence is (33.575131, -117.778007) LatLon - The location of the MapLayers.CircleFence's center. |
getDistance () | Finds the distance from the center of the circular fence to its edge. JavaScript // Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); alert('Radius of this CircleFence is '+ myCircleFence.getDistance() +' '+myCircleFence.getUnits()); // Radius of this CircleFence is 0.5 mi Number - The radius of the MapLayers.CircleFence. The units of this can be found with a call to MapLayers.CircleFence.getUnits. |
getUnits () | Finds the string abbreviation of the units that the circular fence is being measured in, which will be a DistanceUnit code. JavaScript // Create a CircleFence in Los Angeles with a radius of half a kilometer myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.KILOMETERS, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); alert('Units used for this CircleFence is '+myCircleFence.getUnits()); // Units used for this CircleFence is km String - The appropriate DistanceUnit. |
setCenter (LatLon loc) | Sets the center of the MapLayers.CircleFence to a certain latitude-longitude location. JavaScript // Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); document.onclick = myTestFunction; function myTestFunction() { myCircleFence.setCenter(new Telogis.GeoBase.LatLon(33.566795,-117.769035)); };
|
setRadius (Number distance, String units) | Sets the radius of the MapLayers.CircleFence in given units. JavaScript // Create a CircleFence in Los Angeles with a radius of half a mile myCircleFence = new Telogis.GeoBase.MapLayers.CircleFence({ id: 'circle_fence', parent: map, center: new Telogis.GeoBase.LatLon(33.575131,-117.778007), radius: 0.5, units: Telogis.GeoBase.DistanceUnit.MILES, fillColor: new Telogis.GeoBase.Color(0,18,255,0.2), lineColor: new Telogis.GeoBase.Color(0,18,255,0.9), lineWidth: 1, show: true }); document.onclick = myTestFunction; function myTestFunction() { // Change radius of the circle fence from 0.5 miles to 5 kilometers myCircleFence.setRadius(5,Telogis.GeoBase.DistanceUnit.KILOMETERS); };
|