If I set a series of pushpins throughout the US and a user zooms in to a particular area on the map - is there a way for the user to click a button (start an event) that would give the user all the lat/lon of ONLY the pushpins that are in the area (extents of the map) which they are zoomed into I.E. - I set 500 pushpins across the US and the user zooms into NY and there are 10 pushpins in NY - how can I get the lat/lon of just those 10 pushpins where the user has zoomed into


Re: Get lat/lon of pushpins in map extents


This is about the concept of bounding box. I would also be interested in knowing if there is a supported way to get a list of shapes in the current bounding box.

Since I don't know if there is a better way to do this, I can suggest you this non-optimal solution, hoping that it is enough for you.

You can retrieve the current bounding box, by calling the VEMap.GetMapView function. This will return you a VELatLongRectangle object which will contain all the information you need about the visible coordinates.
At this point you may create a simple IsInBoundingBox function that takes a VELatLong object and a VELatLongRectangle, returning true if that location is internal to the bounding box.
Now it's time to loop over your thousands of shapes checking what's inside and what's not. Save the ones that are inside the box, and return them at the end of the loop

Not very fast, but it should work! If it does, it would be great for the rest of the community if you could put the code here. I am sorry if I don't write a snippet for you, but I am a little busy right now, however let us know if you have any trouble and we will work it out.

I would love to have a VEMap.GetVisibleShapes, somebody let me know if it exists!


Re: Get lat/lon of pushpins in map extents



Thanks for your response!! I sort of took the long way that you recommended.

Using the following JS I am able to get the top left and bottom right lat/lon of the map extents as you stated:

var VELatLongRectangle = map.GetMapView();

var topLeft = VELatLongRectangle.TopLeftLatLong;

var botRight = VELatLongRectangle.BottomRightLatLong;

I then take these values and send them back to VB via Web Services/AJAX; I then run a SQL statment against my DB getting all the data I need; then I compare the lat/lon from each row of the table to see if the lat/lon are within the map extents:

if (deliveryLatitude < mapExtentsList(0) And deliveryLatitude > mapExtentsList(2) And deliveryLongitude > mapExtentsList(1) And deliveryLongitude < mapExtentsList(3)) Then

'add your code here

end if


deliveryLatitude = lat from DB

deliveryLongitude = lon from DB

mapExtentsList(0) = top left lat from VE map extents

mapExtentsList(1) = top left lon from VE map extents

mapExtentsList(2) = bottom right lat from VE map extents

mapExtentsList(3) = bottom right lon from VE map extents


Re: Get lat/lon of pushpins in map extents



Just one thing to add to this, pass the lat long into sql and filter the data there rather than bringing it back into your vb code. Just use SQL's BETWEEN comparer to compare the latitude/longitude of each point in the database to the lat/lon of the bounds.

Much quicker that way

Brian Norman


Re: Get lat/lon of pushpins in map extents


THANKS Brian!! Much quicker that way!! :-)

Re: Get lat/lon of pushpins in map extents


And to follow up, the next version of SQL Server (2008) offers some spatial functions and datatypes that will allow you to do much more then this in the database in the future, like complex polygons, circles, unions of sereral polygons, buffers on lines etc. For now, using the sql "between" for a square bounding box is going to be very quick.

If your interested in some of this their is an introductory video here: