[fusion-dev] Markers in Openlayers.

Nolte, Tim Tim.Nolte at ipcswirelessinc.com
Tue Dec 8 17:04:50 EST 2009


If you look at the API for OpenLayers you'll find that their roadmap is pushing to retire the old Markers way of doing things in favor of just using Vector features. I have already implemented this to added a geocoded point to Fusion. Here is a sample of my code:

var map = Fusion.getMapById('Map');

var styleMap = new OpenLayers.StyleMap({
	"default": new OpenLayers.Style({
		graphicName: "${graphicName}",
		strokeColor: "${strokeColor}",
		strokeOpacity: "${strokeOpacity}",
		strokeWidth: "${strokeWidth}",
		fillColor: "${fillColor}",
		fillOpacity: "${fillOpacity}",
		pointRadius: "${pointRadius}",
		pointerEvents: "visiblePainted",
		label : "  ${label}",
		
		fontColor: "#000000",
		fontSize: "11px",
		fontFamily: "Arial",
		fontWeight: "bold",
		labelAlign: "${align}",
		labelXOffset: "${xOffset}",
		labelYOffset: "${yOffset}"
	})
});

// remove any existing Geocoded Point vector layers
for (var i=0; i<map.oMapOL.layers.length; i++) {
	var layer = map.oMapOL.layers[i];
	if (layer.name == 'Geocoded Points') { layer.destroy(); }
}
// create Geocoded Point vector layer
var vectorLayer = new OpenLayers.Layer.Vector('Geocoded Points', {styleMap: styleMap});
map.oMapOL.addLayers([vectorLayer]);
var newPoint = new OpenLayers.Geometry.Point(parseFloat(nLon), parseFloat(nLat), {style: "default"});
var pointFeature = new OpenLayers.Feature.Vector(newPoint);
pointFeature.attributes = {
	graphicName: "circle",
	strokeColor: "#000000",
	strokeOpacity: 1,
	strokeWidth: 1,
	fillColor: "#FFFFFF",
	fillOpacity: 1,
	pointRadius: 9,
	
	label: sLabel,
	align: 'lc',
	// positive value moves the label to the right
	xOffset: 50,
	// negative value moves the label down
	yOffset: -15
};
var newStar = new OpenLayers.Geometry.Point(parseFloat(nLon), parseFloat(nLat), {style: "default"});
var starFeature = new OpenLayers.Feature.Vector(newStar);
starFeature.attributes = {
	graphicName: "star",
	strokeColor: "#000000",
	strokeOpacity: 1,
	strokeWidth: 1,
	fillColor: "#0066CC",
	fillOpacity: 0.5,
	pointRadius: 8,
	
	label: '',
	align: 'lc',
	// positive value moves the label to the right
	xOffset: 0,
	// negative value moves the label down
	yOffset: 0
};
vectorLayer.addFeatures([pointFeature, starFeature]);

----
Timothy J Nolte - tnolte at ilpcs.com
Network Planning Engineer

Sprint Nextel
4717 Broadmoor Ave, Suite G
Kentwood, MI 49512

Office: 616-656-5163
PCS:    616-706-2438
Fax:    616-554-6484


-----Original Message-----
From: fusion-dev-bounces at lists.osgeo.org [mailto:fusion-dev-bounces at lists.osgeo.org] On Behalf Of GordonL
Sent: Tuesday, December 08, 2009 4:48 PM
To: fusion-dev at lists.osgeo.org
Subject: Re: [fusion-dev] Markers in Openlayers.


Hi Paul, 
did this get implemented?  I am very interested in Markers lately!

gordon


Paul Deschamps wrote:
> 
> Hi All,
> 
> Want your two cents on the prospect on adding  the
> "OpenLayers.Layer.Markers" class  into
> trunk/lib//lib/OpenLayers/OpenLayers.js
> 
> Adding a markers layer is quite easy as long as that class is loaded
> (obviously ;)
> 
> Here's a very basic implementation of adding a OL marker in a Fusion app.
> 
> function addMarker(iLon,iLat){
> 
>     // get the map and map widget
>     var mapWidget = Fusion.getMapById('mapArea');
>     var maps = mapWidget.getAllMaps();
>     var map = maps[0];
> 
>     // create a markers layer called "Markers"
>     var markers = new OpenLayers.Layer.Markers( "Markers" );
> 
>     // add the marker layer to the OL Map.
>     mapWidget.oMapOL.addLayer(markers);
> 
>     // OL Image related stuff.
>     var size = new OpenLayers.Size(10,17);
>     var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
>     var icon = new OpenLayers.Icon('
> http://boston.openguides.org/markers/AQUA.png',size,offset);
> 
>     // add the marker.
>     markers.addMarker(new OpenLayers.Marker(new
> OpenLayers.LonLat(iLon,iLat),icon));
> }
> 
> Do we want to add the OpenLayers.Layer.Markers class in 1.1?
> 
> Cheers
> 
> Paul D.
> 
> _______________________________________________
> fusion-dev mailing list
> fusion-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-dev
> 
> 

-- 
View this message in context: http://n2.nabble.com/Markers-in-Openlayers-tp2061979p4135608.html
Sent from the Fusion Developers mailing list archive at Nabble.com.
_______________________________________________
fusion-dev mailing list
fusion-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fusion-dev



More information about the fusion-dev mailing list