Tuesday, May 26, 2009

Creating Infowindow Boxes for Displayed Polygons


So, I wanted to construct an infobox for each of the polygons that come up in my impervious surfaces browser. Originally, the php script that I wrote was using the DOM to create a kml file, but I adapted the code into the following, which creates the HTML for a little text box that I pop up:


PhP:

$pound='#';
$parcelLink1='Kitsap County GIS';
$parcelLink=$parcelLink1.$parcelLink2.$parcelLink3;

$parcelLink11='Kitsap County GIS';
$parcelLink10=$parcelLink11.$parcelLink12.$parcelLink13;

$textbox0="

Surface type: ";
$textbox1=$row['Surface_Ty'];
$textbox2="
Surface Area (sqft): ";
$textbox3=intval($row['Area']);
$textbox3a=" Sqft";
$textbox4="
Impervious Surface Units: ";
$textbox5=((intval($row['ISU']*100))/100);
$textbox6="
Assigned Account: ";
$textbox7=$row['AccountNum'];
$textbox8="
Assigned Address: ";
$textbox9=$row['Address_fr'];
$textbox10="
Total Area for this account: ";
$textbox11=$TotalAreaNew;
$textbox12=" Sqft";
$textbox13="
Total ISUs for this account: ";
$textbox14=$TotalIsuNew;
$textbox15="
Parcel Information: ";
$textbox16=$parcelLink;
$textbox17="
Owner Information: ";
$textbox18=$parcelLink10;
$textbox19="

";

$textbox=$textbox0.$textbox1.$textbox2.$textbox3.$textbox3a.$textbox4.$textbox5.$textbox6.$textbox7.$textbox8.$textbox9.$textbox10.$textbox11.$textbox12.$textbox13.$textbox14.$textbox15.$textbox16.$textbox17.$textbox18.$textbox19;

Then, later, I construct a textbox when I plot the polygon and assign a listener that knows to open the new infowindow when any of the polygons I just drew are clicked on. Assigning the listener was actually the hardest part about making the new infowindow boxes – I was thinking that I needed to assign the listener to create the window on each polygon, when in actuality I just needed to assign the listener to the main window (because you can only have one infowindow at a time) and give the listener some coordinates at which to open the new infowindow (the coordinates, in case you are interested, are the coordinates at the center of each polygon).

So the Php script takes the encoded OGC geometry objects for the polygons that are selected from my user’s query. It parses those polygons out into the corrdinates and reassembles them into a form that is inputtable into new gpolygon() as an array of points. Then it assigns a listener to that polygon which tells the map that if that polygon is clicked on – display all of the information about the polygon (as parsed and created by the script earlier) in a data infowindow that is cenetered on the center coordinates of the polygon.

And it works.

Here’s the newest version:

http://freeforthepicking.com/imagery/kmlmap5.5.SITUS.php

If you want to try it out – enter account number 1101850 as an example or try a street address of 3027 olympus

Dominic

No comments:

Post a Comment