[mapguide-users] window open
Mark Pendergraft
markp at Meadgilman.com
Fri Feb 20 14:58:26 EST 2009
What you have looks pretty good, except that you will need to create a
box that covers your point for the mgPolygon.
First you need to create a MgCoordinateCollection to populate a
MgLinearRing, then you use $geometryFactory->CreatePolygon(mgLinearRing,
nothing);
Take a look at this function. It uses MgGeometryFactory, and a MgPoint
to create a box that surrounds the point supplied. The function returns
a MgPolygon
Private Function GetBoundingBox(ByVal geomFact As MgGeometryFactory,
ByVal point As MgPoint) As MgPolygon
Dim pgon As MgPolygon
Dim coordColl As New MgCoordinateCollection
coordColl.Add(geomFact.CreateCoordinateXY(point.Coordinate.GetX
- 5, point.Coordinate.GetY + 5))
coordColl.Add(geomFact.CreateCoordinateXY(point.Coordinate.GetX
+ 5, point.Coordinate.GetY + 5))
coordColl.Add(geomFact.CreateCoordinateXY(point.Coordinate.GetX
+ 5, point.Coordinate.GetY - 5))
coordColl.Add(geomFact.CreateCoordinateXY(point.Coordinate.GetX
- 5, point.Coordinate.GetY - 5))
coordColl.Add(geomFact.CreateCoordinateXY(point.Coordinate.GetX
- 5, point.Coordinate.GetY + 5))
Dim linRing As MgLinearRing =
geomFact.CreateLinearRing(coordColl)
pgon = geomFact.CreatePolygon(linRing, Nothing)
Return pgon
End Function
You can create a MgPoint by doing the following:
Dim geomFact As New MgGeometryFactory
Dim coord As MgCoordinate = geomFact.CreateCoordinateXY(X,
Y)
' create the actual mggeometry
Dim point As MgPoint = geomFact.CreatePoint(coord)
The LayerResourceId & schema can be obtained like so:
' get the layer to search
Dim layer as MgLayer =
Map.GetLayers().GetItem("your_layer_name_here")
' Get the layer resource identifier
Dim LayerResId As New
MgResourceIdentifier(layer.GetFeatureSourceId())
' get the layer default schema
Dim layerSchema as string =
layer.GetFeatureClassName
As a side note. Everytime you assign a value to the MgFeatureReader,
you will need to close it immediately afterwards. This has screwed me a
few times.
After you get the point, you can use the MgFeatureReader to getString(),
or getInteger(), etc.... to obtain the values that you need to pass to
your pop-up window.
Out of curiosity, why did you choose to go this route instead of the
pop-up MapTip with a link to your new window? The only reason I have
code like this in my map is so I can zoom to a point returned from
Google Maps when the user enters an address into a search field. I much
prefer the simplicity of letting MapGuide do the grunt work. ;)
-Mark
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of DYUTI
Sent: Thursday, February 19, 2009 11:03 PM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] window open
hi....
thank u very much mark..
But i've still doubts in this .shall i use
"
$geometryFactory = new MgGeometryFactory();
$mgPolygon = $geometryFactory->Create mgPolygon($gp.x,$gp.y); "
to create mg polygons from the N/E coordinates.
Instead of "geom" u have used in vb coding shall i use this
$mgPolygon.Then
for getting LayerResourceID & Schema shall i use coding or can i
directly
give that values..
Thanks and regards
dyuti
Mark Pendergraft wrote:
>
> In VB:
>
> Dim geom As MgGeometry
> Dim query As New MgFeatureQueryOptions()
> query.SetSpatialFilter("Geometry", geom,
> MgFeatureSpatialOperations.Intersects)
> Dim fr as MgFeatureReader = FeatService.SelectFeatures(LayerResId,
> "Default:Temp", query)
>
> Note that geom is a mggeometry object used to query the layer. It
could
> be a point, polygon, etc.
> LayerResId refers to the MgResourceIdentifier for a specified layer
> "Default:Temp" is the layer's schema name.
>
> In your case, you will probably want to create a MgPolygon from the
> point the user clicked. Then you will use the layer containing the
> points you want to display info about to get your LayerResId and
default
> schema.
>
> -Mark
>
> -----Original Message-----
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of DYUTI
> Sent: Wednesday, February 18, 2009 11:32 PM
> To: mapguide-users at lists.osgeo.org
> Subject: Re: [mapguide-users] window open
>
>
> hi all.....
> any one plss tell me how to generate spatial filter.
> any suggestions will be appreciated
>
> thanks and Regards
>
> dyuti
>
> DYUTI wrote:
>>
>> Thank u mark ....i'll try this
>>
>> regards
>> dyuti
>>
>> Mark Pendergraft wrote:
>>>
>>> Here are 2 ways to accomplish what you are trying to do:
>>>
>>> Option 1:
>>> You have a widget which inherits Fusion.Tool.Canvas.
>>> Use the mousedown even to get the coordinates clicked
>>> Then use
>>> "var p = this.getMap().getEventPosition(e);" to get the event
> position
>>> "var gp = this.getMap().pixToGeo(p.x, p.y);" to get the N/E at that
>>> position
>>>
>>> Then send your northing and easting to a PHP page and use it to
> generate
>>> a spatial filter (you may want to create a mgPolygon from your N/E
as
>>> your spatialfilter in order to make sure you cover the point)
>>>
>>> Return the selected point, and send it to another page to create
your
> pop
>>> up window populated with the relevant information.
>>>
>>> Option 2:
>>> Use the URL feature in studio to show a link. Use expressions to
> pass
>>> the points information into the link, and have the link directed to
a
>>> custom page which will populate itself with the relevant data.
>>>
>>>
>>> Seeing as you are new to MapGuide, I would highly recommend option
2,
> as
>>> it requires very little coding and is very easy and user friendly.
I
>>> have attached a photo of what the URL maptip looks like in my map.
> In
>>> the picture, the user hovers there mouse over a parcel and the
maptip
>>> pops up with a link to the parcel's page on the county's website.
> All I
>>> have to do is pass the parcel number in the link, which is all done
> by
>>> studio.
>>>
>>> http://n2.nabble.com/file/n2315851/Untitled.jpg
>>>
>>> -Mark
>>>
>>>
>>> DYUTI wrote:
>>>>
>>>> hi..all...
>>>> to open a new window while clicking on the points
> displayed
>>>> on the map where i've to write the coding...In which file i've to
> make
>>>> changes..&what change i've to make...plss help me...
>>>>
>>>>
>>>>
>>>>
>>>> thanks®ards
>>>> dyuti
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context:
> http://n2.nabble.com/window-open-tp2295629p2351717.html
> Sent from the MapGuide Users mailing list archive at Nabble.com.
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
>
--
View this message in context:
http://n2.nabble.com/window-open-tp2295629p2357432.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
More information about the mapguide-users
mailing list