I am working on a GIS Application. What progress i have done is that i have loaded a KML Layer on Google MAPS API and i am plotting the routes between the points. This is GUI Part. Now how do i save the latitudes and longitudes which i click on the maps in database and later on retreive them to display it on the maps??. I am using POSTGRE SQL as Database and Google Maps API for plotting the points. Should i capture the latitudes and longitudes on onclick function? And after capturing what are the next steps?. And what datatype can be used to capture Geospatial Data in PostgreSql. Please guide.
You can use Geography or Geometry datatype to store your polylines. Take a look at this page if you're not familiar with them. As you write it, you can capture latitude and logitude of each clicked point during onclick event, then construct your object and store it in your DB.
Depending on your needs, you can also determine that a polyline is a list of points, which are defined by a latitude and a longitude. Create a table with three fields (idRoute / lat / lng) and store all your points in this table. Then, to display your route in your map, just load all the points where idRoute = route you want to display.
Related
I have a list of geocodes in latitude longitude format in a mysql db. Are there any free APIs that I can use to filter (using a json file containing the coordinates or any other format) those coordinates to a radius (ex: 1Km) within another given coordinate and get the results back in Json format or any other format that I can work with in C#.
I am aware I can do this manually by using the Haversine formula.
What I need is the following.
Whenever I add any instance of object in my website, I need the server to add the location of the object to my own map either in Google maps or Bing maps (Bing maps docs are more clear therefore I'm going to use Bing).
Later, whenever I view the object in my site, the map should point to the location of the object and other my map objects in the same map.
How can this be achieved? Do I need to hold all the coordinates and object descriptions in my server, or somehow it is saved in the google or bing.
I went through the docs, but couldn't find any information I need.
You need to store them on your server and load them into the map on your webpage. There are ways with both google (fusion tables) and bing (spatial data services) of storing them with the provider but if you are already storing a copy for your website you are better off keeping them there for the map rather than maintaining two copies.
I'm not sure how technical you are but this best architecture approach is this:
1) Write a database query that finds objects to show on your map, ideally filtered by whatever the user can use to filter objects elsewhere on your site. Add to this query a filter by geographical bounding box (the range of latitude and longitude that can be seen on your map at any one point). The bounding box filter is just a simple sql BETWEEN clause but will mean you dont have to load every single object on to the map.
2) write a "webservice" that uses the database query in 1) and turns the results into JSON. This approach will lead to a much cleaner seperation between your mapping code in javascript and your server side code in the webservice.
3) Write your mapping frontend in Bing using javascript and use something like Jquery to read data from the webservice as the map is moved around re-load data that know should be shown on the new map view. As the data will be in JSON its much easier as JSON will just give you javascript versions of your objects
I'm using Google Maps API to display some information to my users. But I want the data is country and state specific. Now is there a way to display data to a state and country without having to provide the LAT and LONG?
I want to highlight the state and once the use click on it display some information.
The Google Maps API v3 uses geographical coordinates (latitude and longitude) for location information on the map. To position state and or country polygons on the map you will need data for them (which will need to include their geographic coordinates). There are publicly available polygons, the Natural Earth data set being one that is available in FusionTables.
See this similar question
or this one
This is the scenario...
I have a set of lat/long data stored in a db table[id, lat, long, location]. I'm using geo-location to get a user's current physical location(lat and long). When this user accesses the app, allows his location to be shared, I want to get those coordinates that are around his current coordinates, and plot them on a Google Map.
How can this be done?
Example: I have the coordinates for hotels in a city stored in my DB table. When a user visits this city and accesses my app, I want to get from my DB and plot on map only those coordinates that are around him in a certain radius.
Note: I'm using PHP for server side stuff.
Any help is appreciated!
You describe a store locator: finding POIs within a radius around a particular point. A store locator finds POIs within a radius around a location. The details in Google's example are different (you find the centre point via browser geolocation and have a fairly small radius) but the principle is exactly the same.
Google's article: developers.google.com/maps/articles/phpsqlajax_v3
I have a website where people can view some places on a google map, which are stored with a lat/lng coordinate. The storage is mongodb. Now when the user navigates the map, I need to lookup up which places now are in the visible part of the map.
I'm new to mongo, but have looked at the spatial part. My question is now an effective way to do this lookup.
Do I need to make a ensureIndex each time the user navigates the map, and how do I then query all places within the visible boundaries of the map?
According to the mongo docs, you can query within a bounding box like so
box = [[40.73083, -73.99756], [40.741404, -73.988135]]
db.places.find({"loc" : {"$within" : {"$box" : box}}})
The key point here is the use of within to query within a bounding box.
In order to get the values for your box, just get the bounds of the google map like so
map.getBounds()
Where map is your google maps object. getBounds will return a LatLngBounds object from which you can build your box to query mongo.
As for ensureIndex, you should do that once as far as I know.