[OpenLayers-Users] creating a popup at the moment a vector featureis created

Tito, Joseph Joseph.Tito at cobham.com
Fri Oct 7 09:49:40 EDT 2011


Puneet,

Here is some pseudo code and snippets that might help you get started:

1) Register an event listener for when the user clicks the map

	map.events.register('click', map, createFeatureAtLocation);

2) Grab the location the user clicked the map

	function createFeatureAtLocation(event) {
	
		// event.xy.x and event.xy.y is the pixel location of
the mouse click
	}

3) At that location, create your vector feature, add it to a layer
4) Create a popup at the same location

	Popup examples:
http://openlayers.org/dev/examples/popupMatrix.html

Good luck!

-----Original Message-----
From: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Puneet
Kishor
Sent: Thursday, October 06, 2011 2:55 PM
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] creating a popup at the moment a vector
featureis created

I want to accomplish the following --

1. the user clicks on the map
2. a vector feature is created, say, an arrow (or whatever) 3. a small
popup is created right next to the feature with a 
   couple of feature attributes in it. The popup would be 
   anchored to the feature at a predefined point, say, bottom 
   left.

like so

  +-----------+
  | name: foo |
  | rate: 20  |
  +-----------+
  ^
 /|\
  |
  |


I don't know how to accomplish #3 above.

--
Puneet Kishor

_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list