<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [fusion-dev] Creating Vector Points on the Map from Task Pane</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>vectorLayer is an OL layer. It is created on the line:<BR>
<BR>
vectorLayer = new OpenLayers.Layer.Vector('Geocoded Points'...<BR>
<BR>
With this code I can see using firebug that the vector layer is getting created but the point data seems to somehow be invalid.<BR>
<BR>
- Tim<BR>
<BR>
----<BR>
Timothy J Nolte - tnolte@ilpcs.com<BR>
Network Planning Engineer<BR>
<BR>
iPCS Wireless, Inc.<BR>
4717 Broadmoor Ave, Suite G<BR>
Kentwood, MI 49512<BR>
<BR>
Office: 616-656-5163<BR>
PCS: 616-706-2438<BR>
Fax: 616-554-6484<BR>
Web: www.ipcswirelessinc.com<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: pdescham49@gmail.com on behalf of Paul Deschamps<BR>
Sent: Mon 11/23/2009 11:11 AM<BR>
To: Nolte, Tim<BR>
Cc: fusion-dev@lists.osgeo.org<BR>
Subject: Re: [fusion-dev] Creating Vector Points on the Map from Task Pane<BR>
<BR>
Hi,<BR>
<BR>
1 question : is "vectorLayer" a OL vector layer? i don't see the code where<BR>
you create that layer.<BR>
<BR>
Cheers<BR>
<BR>
Paul D.<BR>
<BR>
<BR>
On Sat, Nov 21, 2009 at 12:30 AM, Nolte, Tim<BR>
<Tim.Nolte@ipcswirelessinc.com>wrote:<BR>
<BR>
> OK Guys,<BR>
><BR>
> So I've been banging my head against the wall trying to figure out how<BR>
> to get a geocoded point to display as a vector star on the map. I've got<BR>
> things working to the point of getting my lat/long and zooming the map<BR>
> to the extents that the point falls in. The part that I just can't seem<BR>
> to get working, no matter what combination I try, is taking my lat/long<BR>
> and sticking a point(star) on the map. I'm including my code so you can<BR>
> see where I'm at. You'll notice that in some cases I've got some<BR>
> hard-coded items, this is just due to my custom widget not really being<BR>
> general purpose anyways. Any tips here would be hugely appreciated.<BR>
> Thanks!<BR>
><BR>
> function GetParent() {<BR>
> if (parent.Fusion) {<BR>
> return parent;<BR>
> } else if (parent.parent.Fusion) {<BR>
> return parent.parent;<BR>
> }<BR>
> return null;<BR>
> }<BR>
><BR>
> function getMapAddress() {<BR>
> return<BR>
> GetParent().Fusion.applicationDefinition.widgetSets[0].widgetTagsByName.<BR>
> menuMapAddress;<BR>
> }<BR>
><BR>
> function createPoint(nLat, nLon, sLabel) {<BR>
> var OpenLayers = GetParent().OpenLayers;<BR>
> var mapWidget = getMapAddress().getMapWidget();<BR>
> var json = getMapAddress().extension;<BR>
><BR>
> // calculate & zoom to new extents<BR>
> var ur = new Object;<BR>
> var ll = new Object;<BR>
> ur.x = nLon;<BR>
> ll.x = nLon;<BR>
> ur.y = nLat;<BR>
> ll.y = nLat;<BR>
><BR>
> // create one default layer, unless other widgets have created<BR>
> it<BR>
> var vectorLayer = mapWidget.oMapOL.getLayersByName('Geocoded<BR>
> Points');<BR>
> var mapServerLayer =<BR>
> mapWidget.oMapOL.getLayersByName('ipcs_cell_sites');<BR>
><BR>
> if (vectorLayer) { mapWidget.oMapOL.removeLayer(vectorLayer,<BR>
> false); }<BR>
> vectorLayer = new OpenLayers.Layer.Vector('Geocoded Points', {<BR>
> styleMap: new OpenLayers.StyleMap({'default':{<BR>
> strokeColor: "#00FF00",<BR>
> strokeOpacity: 1,<BR>
> strokeWidth: 3,<BR>
> fillColor: "#000000",<BR>
> fillOpacity: 0.5,<BR>
> pointRadius: 6,<BR>
> pointerEvents: "visiblePainted",<BR>
> label : "${label}",<BR>
><BR>
> fontColor: "#000000",<BR>
> fontSize: "7px",<BR>
> fontFamily: "Arial",<BR>
> fontWeight: "bold",<BR>
> labelAlign: "rt",<BR>
> labelXOffset: "${xOffset}",<BR>
> labelYOffset: "${yOffset}"<BR>
> }})<BR>
> });<BR>
><BR>
> // create a point feature<BR>
> var point = new OpenLayers.Geometry.Point(nLon, nLat);<BR>
> var pointFeature = new OpenLayers.Feature.Vector(point);<BR>
> pointFeature.attributes = {<BR>
> label: sLabel,<BR>
> // positive value moves the label to the right<BR>
> xOffset: 50,<BR>
> // negative value moves the label down<BR>
> yOffset: 0<BR>
> };<BR>
><BR>
> mapWidget.oMapOL.addLayer(vectorLayer);<BR>
> vectorLayer.maxScale = mapServerLayer.maxScale;<BR>
> vectorLayer.numZoomLevels = mapServerLayer.numZoomLevels;<BR>
> vectorLayer.addFeatures([pointFeature]);<BR>
><BR>
> var zoomFactor = json.Factor ? json.Factor[0] : 2;<BR>
> var margin = .0125;<BR>
> var zoom_size = zoomFactor * margin / 2;<BR>
> //var zoom_size = zoomFactor * Math.max( Math.abs(ur.x - ll.x),<BR>
> Math.abs(ur.y - ll.y)) / 2;<BR>
> var cX = (ur.x + ll.x)/2;<BR>
> var cY = (ur.y + ll.y)/2;<BR>
> ll.x = cX - zoom_size;<BR>
> ur.x = cX + zoom_size;<BR>
> ll.y = cY - zoom_size;<BR>
> ur.y = cY + zoom_size;<BR>
> mapWidget.oMapOL.zoomToExtent(new<BR>
> OpenLayers.Bounds(ll.x,ll.y,ur.x,ur.y));<BR>
> mapWidget._oCurrentExtents = mapWidget.oMapOL.getExtent();<BR>
> }<BR>
><BR>
> ----<BR>
> Timothy J Nolte - tnolte@ilpcs.com<BR>
> Network Planning Engineer<BR>
><BR>
> iPCS Wireless, Inc.<BR>
> 4717 Broadmoor Ave, Suite G<BR>
> Kentwood, MI 49512<BR>
><BR>
> Office: 616-656-5163<BR>
> PCS: 616-706-2438<BR>
> Fax: 616-554-6484<BR>
> Web: www.ipcswirelessinc.com<BR>
><BR>
> _______________________________________________<BR>
> fusion-dev mailing list<BR>
> fusion-dev@lists.osgeo.org<BR>
> <A HREF="http://lists.osgeo.org/mailman/listinfo/fusion-dev">http://lists.osgeo.org/mailman/listinfo/fusion-dev</A><BR>
><BR>
<BR>
<BR>
<BR>
--<BR>
Paul Deschamps<BR>
Applications Specialist<BR>
DM Solutions Group Inc.<BR>
<BR>
Office: (613) 565-5056 x28<BR>
pdeschamps@dmsolutions.ca<BR>
<A HREF="http://www.dmsolutions.ca">http://www.dmsolutions.ca</A><BR>
<A HREF="http://research.dmsolutions.ca">http://research.dmsolutions.ca</A><BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>