<p class="MsoNormal">What it essentially comes down to is I haven't figured out
how to get an array of coordinates that represent all the filtered placemarks
on the map.<span style> </span>If I could get this, it
would be fairly easy to set and center the BBox.<span style> </span>Does anyone have any examples of this for KML
on a vector layer implemented using the http protocol?<span style> </span>Thanks a lot.</p>
<br clear="all"><span style="font-family:georgia,serif">Aaron E-J</span><br style="font-family:georgia,serif"><span style="font-family:georgia,serif"><a href="http://otherrealm.org" target="_blank">http://otherrealm.org</a></span><br style="font-family:georgia,serif">
<span style="font-family:georgia,serif"><a href="http://aaronej.blogspot.com" target="_blank">http://aaronej.blogspot.com</a></span><br style="font-family:georgia,serif"><span style="font-family:georgia,serif">Vision without action is a daydream,</span><br style="font-family:georgia,serif">
<span style="font-family:georgia,serif">Action without vision is a nightmare,</span><br style="font-family:georgia,serif"><span style="font-family:georgia,serif">One needs both to succeed.</span><br><br><div class="gmail_quote">
On Thu, Jul 5, 2012 at 1:45 PM, Someone [via OSGeo.org] <span dir="ltr"><<a href="mailto:ml-node+s1560n4986344h30@n6.nabble.com" target="_blank">ml-node+s1560n4986344h30@n6.nabble.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here is a link to the kml file that I am using: <a href="http://66.230.78.217/venuesComplete.kml" rel="nofollow" target="_blank">http://66.230.78.217/venuesComplete.kml </a></blockquote><div><br>On
<span class="post-date float-left">
<span id="d1341501462979-719">2012-07-05 11:17, Someone whote:<br></span></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm getting a "bounds is null" error when I try to implement this line
of code. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Probably something simple I'm not doing but I can't figure out
what this is. And suggestions appreciated.
<br></blockquote></div><br><pre>function showVenues(state, city, venue){
var kmllayer = new OpenLayers.Layer.Vector(
"KML", {
strategies: [filterStrategy, new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "venuesComplete.kml",
format: new OpenLayers.Format.KML({
placemarksDesc:true,
extractStyles: true,
extractAttributes: true
}),
attribution:'coordinates'
})
});
select = new OpenLayers.Control.SelectFeature(kmllayer);
kmllayer.events.on({
"featureselected": onFeatureSelect,
"featureunselected": onFeatureUnselect
});
map.addControl(select);
select.activate();
function onPopupClose(evt) {
select.unselectAll();
}
function onFeatureSelect(event) {
var feature = event.feature;
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
"<h2>"+<a href="http://feature.attributes.name">feature.attributes.name</a> + "</h2>" + feature.attributes.description +'<br>'+feature.attributes.Point.coordinates,
null,
true,
onPopupClose
);
document.getElementById('venueName').value=<a href="http://feature.attributes.name">feature.attributes.name</a>;
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}
clearFilter();
map.zoomToExtent(kmllayer.getDataExtent());
/* get the following message in firebug:
bounds is null
zoomToExtent(bounds=null, closest=undefined)Map.js (line 2250)
showVenues(state="", city="", venue="Fox Theatre - Tucson")index.php (line 1204)
init()index.php (line 1259)
(?)()index.php (line 1126)
f(b=Document index.php#?q=displayGetEventNames&str=||||||||Fox%20Theatre||||||||||||||||date, f=[function()])jquery.min.js (line 2)
f(b=Document index.php#?q=displayGetEventNames&str=||||||||Fox%20Theatre||||||||||||||||date, c=[function()])jquery.min.js (line 2)
f(a=undefined)jquery.min.js (line 2)
f()jquery.min.js (line 2)
error source line:
[Break On This Error]
var center = bounds.getCenterLonLat();
*/
}
function clearFilter(){
filterStrategy.setFilter(null);
}
function setFilter(){
/****returned from a php file via a .post request****
$venueFilters = <<<'EOD'
<script>
filter=new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
EOD;
$firstVenue = true;
foreach ($venueName as $k => $v) {
if ($firstVenue) {
$venueFilters.= <<<EOD
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: 'name',
value: "$v"
})
EOD;
} else {
$venueFilters.= <<<EOD
,
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: 'name',
value: "$v"
})
EOD;
}
$firstVenue = false;
}
$venueFilters.= <<<'EOD'
]
});
setFilter();
</script>
EOD;
*************************************************/
filterStrategy.setFilter(filter);
}
function init() {
map = new OpenLayers.Map('map');
var google_map_layer = new OpenLayers.Layer.Google(
'Google Map Layer',
{
type: google.maps.MapTypeId.HYBRID
}
);
map.addLayer(google_map_layer);
state="";
state+=document.getElementById('stateProvDesc').value;
city="";
city+=document.getElementById('cityZip').value;
venue="";
venue+=document.getElementById('venueName').value;
showVenues(state,city,venue);
map.addControl(new OpenLayers.Control.LayerSwitcher({}));
map.zoomToMaxExtent();
}
</pre>
<div class="signature weak-color">Vision without action is a daydream,
<br>Action without vision is a nightmare,
<br>One needs both to succeed.</div><br>On 7/4/2012 3:17 AM, Tobias Reinicke wrote:<br>
<blockquote cite="mid:CAPitpCZPefxHsr=6H1m4zPX_XSd-EnfsU45-Azibvkf_16Lt9w@mail.gmail.com" type="cite">The same function is also available for vector layers;<br>
<a href="http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.getDataExtent" target="_top" rel="nofollow">http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.getDataExtent</a>
<div>
<br>
</div>
<div>I presume you will have set your kml layer up somewhere along
the lines of; </div>
<div><br>
</div>
<div>var myKMLLayer = new OpenLayers.Layer.Vector("KML", {<br>
<br>
strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.HTTP({<br>
url: "whatever",<br>
format: new OpenLayers.Format.KML({<br>
extractStyles: true, <br>
extractAttributes: true,<br>
maxDepth: 2<br>
})<br>
})<br>
};<br>
Then all you do is call</div>
<div>map.zoomToExtent(myKMLLayer.getDataExtent());</div>
<div><br>
</div>
<div>That work for you?</div>
<div>
<br>
</div>
<div>Toby</div>
<div><br>
<br>
<br>
<br>
<div class="gmail_quote">On 4 July 2012 01:21, Aaron E-J <span dir="ltr"><<a href="http://osgeo-org.1560.n6.nabble.com/user/SendEmail.jtp?type=node&node=4985988&i=0" target="_top" rel="nofollow">[hidden email]</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF">
<div><font face="Times New Roman, Times, serif">Do you
have, or know where I could find, an example of this
being implemented on KML</font> layer?<span class="HOEnZb"><font color="#888888"><br>
</font></span>
<pre cols="72"><span class="HOEnZb"><font color="#888888">Aaron E-J
<a href="http://www.otherrealm.org" target="_blank" rel="nofollow">http://www.otherrealm.org</a>
<a href="http://www.prospectdesigns.com" target="_blank" rel="nofollow">http://www.prospectdesigns.com</a></font></span><div class="im">
Vision without action is a daydream,
Action without vision is a nightmare,
One needs both to succeed.
</div></pre>
<div class="im"> On 7/3/2012 5:52 PM, Greg Allensworth
wrote:<br>
</div>
</div>
<div class="im">
<blockquote type="cite">On 7/3/2012 2:11 PM, Aaron E-J
wrote: <br>
<blockquote type="cite">Is there an easy way to center
and zoom the map automatically based on <br>
the placemarks that are on it?I have it so that one
can filter <br>
placemarks based on user input but I'm not sure how
to dynamically <br>
update the map to fit the newly filtered
content.Thanks for any insight <br>
that can be given regarding this matter. <br>
</blockquote>
<br>
An OpenLayers.Layer.Markers instance, has a method
called getDataExtent() This should do most of what you
want. <br>
<br>
It's not automatic, though. You'd still need to call
map.zoomToExtent() after the markers have been added
to the layer. <br>
<br>
<a href="http://dev.openlayers.org/docs/files/OpenLayers/Layer/Markers-js.html" target="_blank" rel="nofollow">http://dev.openlayers.org/docs/files/OpenLayers/Layer/Markers-js.html</a>
<br>
<br>
</blockquote>
<br>
<br>
</div>
</div>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="http://osgeo-org.1560.n6.nabble.com/user/SendEmail.jtp?type=node&node=4985988&i=1" target="_top" rel="nofollow">[hidden email]</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank" rel="nofollow">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<br>
<br>_______________________________________________
<br>Users mailing list
<br><a href="http://osgeo-org.1560.n6.nabble.com/user/SendEmail.jtp?type=node&node=4985988&i=2" target="_top" rel="nofollow">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_top" rel="nofollow">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>