# How to get the bounding box for MarkerLayer?

**URL:** <https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083>\
**Category:** WinForms\
**Created:** [September 5, 2012, 5:49pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083 "2012-09-05T17:49:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@Bob3](https://community.thinkgeo.com/u/Bob3)\
**Post date:** [September 5, 2012, 5:49pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/1 "2012-09-05T17:49:43Z")

</div>

I'd&nbsp;like&nbsp;to&nbsp;zoom&nbsp;the&nbsp;map&nbsp;to&nbsp;set&nbsp;the&nbsp;current&nbsp;extent&nbsp;to&nbsp;the&nbsp;boundingbox&nbsp;of&nbsp;all&nbsp;Markers&nbsp;in&nbsp;a&nbsp;MarkerLayer.&nbsp;&nbsp;How&nbsp;is&nbsp;that&nbsp;done?

bob

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 6, 2012, 4:51pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/2 "2012-09-06T16:51:46Z")

</div>

Hello&nbsp;Bob,&nbsp;  
&nbsp;&nbsp;  
&nbsp;So&nbsp;what’s&nbsp;the&nbsp;MarkerLayer&nbsp;type?&nbsp;SimpleMarkerOverlay?&nbsp;InMemoryMarkerOverlay?&nbsp;If&nbsp;it’s&nbsp;these&nbsp;two,&nbsp;you&nbsp;can’t&nbsp;directly&nbsp;get&nbsp;the&nbsp;boundingbox,&nbsp;but&nbsp;every&nbsp;marker&nbsp;actually&nbsp;is&nbsp;a&nbsp;pointshape,&nbsp;so&nbsp;you&nbsp;can&nbsp;create&nbsp;a&nbsp;InMemoryFeatureLayer&nbsp;and&nbsp;add&nbsp;all&nbsp;the&nbsp;marker&nbsp;into&nbsp;this&nbsp;layer&nbsp;as&nbsp;pointshape,&nbsp;so&nbsp;that&nbsp;you&nbsp;can&nbsp;get&nbsp;this&nbsp;featurelayer’s&nbsp;boundingbox.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Bob3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@Bob3](https://community.thinkgeo.com/u/Bob3)\
**Post date:** [September 6, 2012, 5:00pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/3 "2012-09-06T17:00:50Z")

</div>

Its&nbsp;a&nbsp;SimpleMarkerOverlay.&nbsp;So&nbsp;I&nbsp;guess&nbsp;we&nbsp;go&nbsp;with&nbsp;plan&nbsp;"B",&nbsp;&nbsp;thanks!!&nbsp;  
&nbsp;&nbsp;  
&nbsp;bob

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 6, 2012, 5:23pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/4 "2012-09-06T17:23:50Z")

</div>

Hello&nbsp;Bob,&nbsp;  
&nbsp;&nbsp;  
&nbsp;You&nbsp;are&nbsp;welcome,&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;your&nbsp;problem.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Allen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@Allen](https://community.thinkgeo.com/u/Allen)\
**Post date:** [September 6, 2012, 6:32pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/5 "2012-09-06T18:32:23Z")

</div>

How&nbsp;about&nbsp;using&nbsp;ExtentHelper.GetBoundingBoxOfItems?&nbsp;It&nbsp;doesn't&nbsp;look&nbsp;like&nbsp;the&nbsp;Marker&nbsp;class&nbsp;comes&nbsp;from&nbsp;BaseShape&nbsp;so&nbsp;you&nbsp;probably&nbsp;can't&nbsp;just&nbsp;pass&nbsp;the&nbsp;list&nbsp;of&nbsp;markers,&nbsp;but&nbsp;since&nbsp;you&nbsp;obviously&nbsp;have&nbsp;the&nbsp;coordinates&nbsp;it&nbsp;would&nbsp;be&nbsp;easy&nbsp;build&nbsp;a&nbsp;list&nbsp;of&nbsp;PointShapes&nbsp;to&nbsp;pass&nbsp;to&nbsp;GetBoundingBoxOfItems.&nbsp;  
  
  
  
Allen

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 6, 2012, 6:39pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/6 "2012-09-06T18:39:55Z")

</div>

Hello&nbsp;Allen,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yes,&nbsp;it’s&nbsp;a&nbsp;good&nbsp;way,&nbsp;actually&nbsp;the&nbsp;key&nbsp;part&nbsp;is&nbsp;get&nbsp;the&nbsp;coordinates&nbsp;of&nbsp;marker&nbsp;and&nbsp;become&nbsp;the&nbsp;pointshape,&nbsp;but&nbsp;the&nbsp;way&nbsp;you&nbsp;suggest&nbsp;it’s&nbsp;easier&nbsp;to&nbsp;understand.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;help.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Bob3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@Bob3](https://community.thinkgeo.com/u/Bob3)\
**Post date:** [September 6, 2012, 6:54pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/7 "2012-09-06T18:54:12Z")

</div>

I&nbsp;agree&nbsp;the&nbsp;second&nbsp;way&nbsp;was&nbsp;easier,&nbsp;but&nbsp;now&nbsp;the&nbsp;problem&nbsp;is,&nbsp;that&nbsp;when&nbsp;I&nbsp;set&nbsp;the&nbsp;WinFormMap&nbsp;control’s&nbsp;“CurrentExtent”&nbsp;to&nbsp;that&nbsp;rectangle,&nbsp;it&nbsp;doesn’t&nbsp;include&nbsp;ALL&nbsp;of&nbsp;the&nbsp;points!!&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ideas?&nbsp;&nbsp;I&nbsp;have&nbsp;to&nbsp;zoom&nbsp;out&nbsp;to&nbsp;see&nbsp;them&nbsp;all,&nbsp;which&nbsp;kind&nbsp;of&nbsp;defeats&nbsp;the&nbsp;point&nbsp;of&nbsp;the&nbsp;excercise.&nbsp;&nbsp;:(&nbsp;  
&nbsp;&nbsp;  
&nbsp;bob

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 6, 2012, 7:24pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/8 "2012-09-06T19:24:18Z")

</div>

Hello&nbsp;Bob,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Can&nbsp;you&nbsp;give&nbsp;me&nbsp;all&nbsp;your&nbsp;marker’s&nbsp;location?&nbsp;I&nbsp;can&nbsp;make&nbsp;a&nbsp;test.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Bob3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@Bob3](https://community.thinkgeo.com/u/Bob3)\
**Post date:** [September 7, 2012, 9:10am UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/9 "2012-09-07T09:10:04Z")

</div>

Actually,&nbsp;I&nbsp;don't&nbsp;think&nbsp;that&nbsp;was&nbsp;my&nbsp;problem....but&nbsp;as&nbsp;a&nbsp;simple&nbsp;workaround&nbsp;I&nbsp;want&nbsp;to&nbsp;add&nbsp;a&nbsp;buffer&nbsp;around&nbsp;the&nbsp;bounding&nbsp;box&nbsp;so&nbsp;that&nbsp;I&nbsp;force&nbsp;it&nbsp;to&nbsp;expand&nbsp;a&nbsp;bit&nbsp;beyond&nbsp;the&nbsp;set&nbsp;of&nbsp;Markers.&nbsp;&nbsp;Can&nbsp;you&nbsp;give&nbsp;me&nbsp;some&nbsp;suggestions&nbsp;on&nbsp;how&nbsp;to&nbsp;accomplish&nbsp;that?&nbsp;i.e.,&nbsp;take&nbsp;the&nbsp;bounding&nbsp;box&nbsp;given&nbsp;and&nbsp;add&nbsp;X&nbsp;meters&nbsp;to&nbsp;each&nbsp;side&nbsp;or&nbsp;better&nbsp;X&nbsp;%&nbsp;to&nbsp;each&nbsp;side.  
  
  
  
bob

---

<div class="post-metadata">

**Author:** ![Allen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@Allen](https://community.thinkgeo.com/u/Allen)\
**Post date:** [September 7, 2012, 11:11am UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/10 "2012-09-07T11:11:58Z")

</div>

Bob,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yeah&nbsp;I’ve&nbsp;seen&nbsp;that&nbsp;by&nbsp;using&nbsp;this&nbsp;method&nbsp;to&nbsp;generate&nbsp;a&nbsp;bounding&nbsp;box&nbsp;of&nbsp;vehicle&nbsp;positions…the&nbsp;points&nbsp;that&nbsp;are&nbsp;right&nbsp;on&nbsp;the&nbsp;edges&nbsp;tend&nbsp;not&nbsp;to&nbsp;be&nbsp;rendered.&nbsp;&nbsp;GetBoundingBoxOfItems&nbsp;returns&nbsp;a&nbsp;RectangleShape,&nbsp;so&nbsp;you&nbsp;could&nbsp;use&nbsp;RectangleShape.Buffer.&nbsp;&nbsp;This&nbsp;takes&nbsp;a&nbsp;distance,&nbsp;so&nbsp;you&nbsp;might&nbsp;say&nbsp;extent&nbsp;=&nbsp;RectangleShape.Buffer(RectangleShape.Width&nbsp;\*&nbsp;0.05)&nbsp;or&nbsp;something&nbsp;like&nbsp;that.&nbsp;&nbsp;Also&nbsp;note&nbsp;that&nbsp;depending&nbsp;on&nbsp;what&nbsp;gets&nbsp;sent&nbsp;to&nbsp;it&nbsp;GetBoundingBoxOfItems&nbsp;can&nbsp;return&nbsp;a&nbsp;bounding&nbsp;box&nbsp;with&nbsp;an&nbsp;aspect&nbsp;ratio&nbsp;way&nbsp;out&nbsp;of&nbsp;line&nbsp;with&nbsp;the&nbsp;map&nbsp;(say&nbsp;it’s&nbsp;5&nbsp;times&nbsp;taller&nbsp;than&nbsp;wide&nbsp;or&nbsp;5&nbsp;times&nbsp;wider&nbsp;than&nbsp;tall&nbsp;rather&nbsp;than&nbsp;a&nbsp;normal&nbsp;map&nbsp;that&nbsp;might&nbsp;be&nbsp;between&nbsp;1:1&nbsp;and&nbsp;1.5:1)&nbsp;and&nbsp;MapSuite&nbsp;tends&nbsp;to&nbsp;ignore&nbsp;it.&nbsp;&nbsp;Whenever&nbsp;I&nbsp;use&nbsp;GetBoundingBoxOfItems&nbsp;I&nbsp;automatically&nbsp;follow&nbsp;it&nbsp;with&nbsp;ExtentHelper.GetDrawingExtent&nbsp;which&nbsp;seems&nbsp;to&nbsp;readjust&nbsp;the&nbsp;extent&nbsp;to&nbsp;match&nbsp;the&nbsp;map’s&nbsp;aspect&nbsp;ratio&nbsp;and&nbsp;MapSuite&nbsp;then&nbsp;accepts&nbsp;the&nbsp;new&nbsp;extent.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Allen

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 9, 2012, 4:18pm UTC](https://community.thinkgeo.com/t/how-to-get-the-bounding-box-for-markerlayer/2083/11 "2012-09-09T16:18:38Z")

</div>

Thank&nbsp;you&nbsp;Allen.
