[Dojo-interest] Draw text on openlayers geometry feature

bartonjd bartonjd at gmail.com
Thu Jun 19 18:47:57 EDT 2014


I am working on displaying weather stations on an openlayers map using the
dojo framework.  I would like to draw a circle with a letter in the center. 
Currently I know how to draw circles so that they appear one atop another
however, I have no clue how to add text to add a text object to a geometry
feature.
Page Example:  https://climate-dev-josh.usurf.usu.edu/cmap/cmap/cmap.html
<https://climate-dev-josh.usurf.usu.edu/cmap/cmap/cmap.html>  
 Here is what I have so far.


    var googleHybrid =
{baseLayerName:"GoogleHybrid",baseLayerType:dojox.geo.openlayers.BaseLayerType.GOOGLE,
baseLayerOptions:{type:google.maps.MapTypeId.HYBRID,numZoomLevels:20}};
    climateMap = new dojox.geo.openlayers.map('map',googleHybrid);

    var ny = {
      latitude : 40.71427,
      longitude : -74.00597
    };
    // create a GfxLayer
    var layer = new GfxLayer();
    // create a Point geometry at New York location
    var p = new Point({x:ny.longitude, y:ny.latitude});
    // create a GeometryFeature
    var f = new GeometryFeature(p);
    // set the shape properties, fill and stroke
    f.setFill('white');
    f.setStroke([ 255,255,255]);
    f.setShapeProperties({
      r : 16
    });
    var p2 = new Point({x:ny.longitude, y:ny.latitude});
    // create a GeometryFeature
    var f2 = new GeometryFeature(p2);
    // set the shape properties, fill and stroke
    f2.setFill({'type': 'linear',
            'x1': 0,
            'y1': 0,
            'x2': 0,
            'y2': 20,
            'colors': [{
                offset: 0,
                color: '#000'
            },
            {
                offset: .2,
                color: '#222'
            },
            {
                offset: .6,
                color: '#555'
            }]});
    f2.setStroke([ 255,255,255 ]);
    f2.setShapeProperties({
      r : 14
    });
   
    layer.addFeature(f);
    // add the feature to the layer
    layer.addFeature(f2);
    // add layer to the map
    climateMap.addLayer(layer);
    // fit to New York with 0.1 degrees extent
    climateMap.fitTo({
        position : [ ny.longitude, ny.latitude ],
        extent : 0.1
    });


    climateMap.addLayer(layer);





--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Draw-text-on-openlayers-geometry-feature-tp4002790.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.


More information about the Dojo-interest mailing list