[fusion-dev] Creating Vector Points on the Map from Task Pane

Paul Deschamps pdeschamps at dmsolutions.ca
Mon Nov 23 11:11:45 EST 2009


Hi,

1 question : is  "vectorLayer" a OL vector layer? i don't see the code where
you create that layer.

Cheers

Paul D.


On Sat, Nov 21, 2009 at 12:30 AM, Nolte, Tim
<Tim.Nolte at ipcswirelessinc.com>wrote:

> OK Guys,
>
> So I've been banging my head against the wall trying to figure out how
> to get a geocoded point to display as a vector star on the map. I've got
> things working to the point of getting my lat/long and zooming the map
> to the extents that the point falls in. The part that I just can't seem
> to get working, no matter what combination I try, is taking my lat/long
> and sticking a point(star) on the map. I'm including my code so you can
> see where I'm at. You'll notice that in some cases I've got some
> hard-coded items, this is just due to my custom widget not really being
> general purpose anyways. Any tips here would be hugely appreciated.
> Thanks!
>
> function GetParent() {
>        if (parent.Fusion) {
>                return parent;
>        } else if (parent.parent.Fusion) {
>                return parent.parent;
>        }
>        return null;
> }
>
> function getMapAddress() {
>        return
> GetParent().Fusion.applicationDefinition.widgetSets[0].widgetTagsByName.
> menuMapAddress;
> }
>
> function createPoint(nLat, nLon, sLabel) {
>        var OpenLayers = GetParent().OpenLayers;
>        var mapWidget = getMapAddress().getMapWidget();
>        var json = getMapAddress().extension;
>
>        // calculate & zoom to new extents
>        var ur = new Object;
>        var ll = new Object;
>        ur.x = nLon;
>        ll.x = nLon;
>        ur.y = nLat;
>        ll.y = nLat;
>
>        // create one default layer, unless other widgets have created
> it
>        var vectorLayer = mapWidget.oMapOL.getLayersByName('Geocoded
> Points');
>        var mapServerLayer =
> mapWidget.oMapOL.getLayersByName('ipcs_cell_sites');
>
>        if (vectorLayer) { mapWidget.oMapOL.removeLayer(vectorLayer,
> false); }
>        vectorLayer = new OpenLayers.Layer.Vector('Geocoded Points', {
>                styleMap: new OpenLayers.StyleMap({'default':{
>                        strokeColor: "#00FF00",
>                        strokeOpacity: 1,
>                        strokeWidth: 3,
>                        fillColor: "#000000",
>                        fillOpacity: 0.5,
>                        pointRadius: 6,
>                        pointerEvents: "visiblePainted",
>                        label : "${label}",
>
>                        fontColor: "#000000",
>                        fontSize: "7px",
>                        fontFamily: "Arial",
>                        fontWeight: "bold",
>                        labelAlign: "rt",
>                        labelXOffset: "${xOffset}",
>                        labelYOffset: "${yOffset}"
>                }})
>        });
>
>        // create a point feature
>        var point = new OpenLayers.Geometry.Point(nLon, nLat);
>        var pointFeature = new OpenLayers.Feature.Vector(point);
>        pointFeature.attributes = {
>                label: sLabel,
>                // positive value moves the label to the right
>                xOffset: 50,
>                // negative value moves the label down
>                yOffset: 0
>        };
>
>        mapWidget.oMapOL.addLayer(vectorLayer);
>        vectorLayer.maxScale = mapServerLayer.maxScale;
>        vectorLayer.numZoomLevels = mapServerLayer.numZoomLevels;
>        vectorLayer.addFeatures([pointFeature]);
>
>        var zoomFactor = json.Factor ? json.Factor[0] : 2;
>        var margin = .0125;
>        var zoom_size = zoomFactor * margin / 2;
>        //var zoom_size = zoomFactor * Math.max( Math.abs(ur.x - ll.x),
> Math.abs(ur.y - ll.y)) / 2;
>        var cX = (ur.x + ll.x)/2;
>        var cY = (ur.y + ll.y)/2;
>        ll.x = cX - zoom_size;
>        ur.x = cX + zoom_size;
>        ll.y = cY - zoom_size;
>        ur.y = cY + zoom_size;
>        mapWidget.oMapOL.zoomToExtent(new
> OpenLayers.Bounds(ll.x,ll.y,ur.x,ur.y));
>        mapWidget._oCurrentExtents = mapWidget.oMapOL.getExtent();
> }
>
> ----
> Timothy J Nolte - tnolte at ilpcs.com
> Network Planning Engineer
>
> iPCS Wireless, Inc.
> 4717 Broadmoor Ave, Suite G
> Kentwood, MI 49512
>
> Office: 616-656-5163
> PCS:    616-706-2438
> Fax:    616-554-6484
> Web: www.ipcswirelessinc.com
>
> _______________________________________________
> fusion-dev mailing list
> fusion-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-dev
>



-- 
   Paul Deschamps
   Applications Specialist
   DM Solutions Group Inc.

   Office: (613) 565-5056 x28
   pdeschamps at dmsolutions.ca
   http://www.dmsolutions.ca
   http://research.dmsolutions.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fusion-dev/attachments/20091123/388c8cb3/attachment.html


More information about the fusion-dev mailing list