Friday, 8 January 2016

Showing markers on google map v3 with dynamic zoom level by leveraging sql server to show closest landmarks to the specific latitude and longitude


Latitude measures how far north or south of the equator a place is located. The equator is situated at 0°, the North Pole at 90° north (or 90°, because a positive latitude implies north), and the South Pole at 90° south (or –90°). Latitude measurements range from 0° to (+/–)90°.

Longitude measures how far east or west of the prime meridian a place is located. The prime meridian runs through Greenwich, England. Longitude measurements range from 0° to (+/–)180°.

Well-known text (WKT) is a text markup language for representing vector geometry objects on a map

POINT(Longitude  Latitude )


Steps

1- Create a table in sql server database to store all of your landmarks latitudes and longitudes. 
2- Create a web API/Service that gets the position (latitude and longitude) and returns back the list of land marks closest to the point – it’s configurable to set number of expected landmark and radius of search)
3- Implement UI 




Good reads:
https://technet.microsoft.com/en-us/library/bb964711(v=sql.120).aspx
http://weblog.west-wind.com/posts/2012/Jun/21/Basic-Spatial-Data-with-SQL-Server-and-Entity-Framework-50
http://www.sql-server-helper.com/sql-server-2008/convert-latitude-longitude-to-geography-point.aspx
http://www.spyriadis.net/2010/07/calculate-distance-between-locations-in-sql-server-2008-using-geography/

Similar scenarios:

http://stackoverflow.com/questions/15719951/google-maps-api-v3-auto-center-map-with-multiple-markers
http://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-markers-visible-markers
http://stackoverflow.com/questions/5405539/google-maps-v3-why-is-latlngbounds-contains-returning-false