my question is simply, what is openstreet map's equivalent for google maps map.getBounds() function, to get the max/min lat and long?
Thanks,
You'll need to use a JS-API(e.g. OpenLayers)
The method to use there is getExtent()
Related
I have a table in the SQLite database with 4,000 locations, including latitude and longitude. Based on information from the region provided by MKCoordinateRegion class, how can I get the places that are located in this region from the map? Is It Possible?
First I tried using Haversine formula, but what I did was just sort the places closest to the center of the map. But I want places that are located in a region of the map. Or am I wrong?
Thanks in advance.
You can get the max/min values for latitude and longitude from your MKMapView by accessing the region attribute:
MKCoordinateRegion *mapRegion = myMap.region;
You can then access the maximum and minimum values as follows:
maxLatitude = mapRegion.center.latitude + mapRegion.span.latitudeDelta/2;
minLatitude = mapRegion.center.latitude - mapRegion.span.latitudeDelta/2;
maxLongitude = mapRegion.center.longitude+ mapRegion.span.longitudeDelta/2;
minLongitude = mapRegion.center.longitude- mapRegion.span.longitudeDelta/2;
Hope this helps! If you're storing your data in Core Data, an NSSet, or an NSArray, you can then use an NSPredicate to filter out the results that meet the above criteria.
Here's the documentation for your MKMapView and an MKCoordinateRegion.
Are you trying to find all the places in a rectangular region?
Simply set up your query as such:
find all locations where latitude > mapMinLat
and latitude < mapMaxLat
and longitude > mapMinLon
and longitude < mapMaxLon
where the edges of your map are mapMinLat, mapMaxLat, mapMinLon, mapMaxLon.
If you're looking for a polygonal region, you'll need to use a more advanced algorithm.
I have absolutely no idea if this will solve your problem, but SpatialLite is a 3rd party library that says:
SpatiaLite is an open source library intended to extend the SQLite
core to support fully fledged Spatial SQL capabilities.
Looking at the list of functions there is a whole section named SQL functions that implement spatial operators
Rolling your own sqlite code has been answered many times on SO, for example Compiling custom SQLite for an iPhone app
I am getting lat longs of different locations,and I want to set zoom (span) in a such a way that I can see all (locations) pins on a map.
Pretty much a dup of Positioning MKMapView to show multiple annotations at once.
I found https://stackoverflow.com/a/7642526/191215 the most elegant.
I am having a mkmpaview in which i show different annotations based on address .I dont get any problem whne all the alat lon are different , but whenever i pass the same lat lon pair then instead of showing two annotations like google maps it shows only one pin .
My scenario is like say i have array of lat lon which is pass for adding annotations , the problem occurs when two pair of lat lon are same if three pair are same then also it shows only 1 pin for the 3.
IF someone has came across the same problem , please help me with that solution .
Any suggestions for different approaches would be accepted .
Hope i am clear with my question.
Your question is not very clear, but i will try to interpret what exactly you are asking.
I believe you want to use different annotation images , for the annotations you are adding that have the same longitude and latitude.
The approach isn't very clear, what exactly is the point of adding multiple annotations with different images in the same location?
You could load the annotations more than once, with different images, but i don't think this would have much sense.
You could also assign tags to the annotation images, and call both tags when loading the annotations on map view.
My answer to this question is very simple!
1) First detect each "same" latitude and longitudes.
2) When inserting pin to that particular location (latitude and longitude) use different color pin.
3) When tapping on pin, check the location of pin and if that belongs to one of the locations that we previously identified, write code appropriately to notify user.
Suppose you are displaying address on a label(on annotation view) when tapped on pin. And when you tapped on pin where there are more than one location assigned, try to display addresses on a scroll view so user can determine all the addresses. This way use some simple logic to tackle the situation.
hello i want distance between two place ... means i have two places latitude and longitude then i want distance between that two place
i want something like this...
http://maps.google.com/maps?saddr=23.029772,72.527871&daddr=23.1901748,72.0127743
not like php or .net or java function that give calculate distance ...
if i search result by function it give me 55.61 output for this latitude and logitude and in map it give me 65.5 output. how can i get this in json ot xml or any other formate ?
...there's an in-built function in iOS that will do this for you. Check out the CLLocation documentation. Particularly distanceFromLocation:, which as the name suggests returns the difference between two locations in meters. You can create a CLLocation object using lat and lon.
If you don't want a straight line distance, you need to use the Google Directions API, which is well documented here: http://code.google.com/apis/maps/documentation/directions/
I drop a pin in an MKMapView with longitude and latitude. When I place same longitude and latitude on google map the pin on both are slightly different.
I have a web/iPhone app that renders a map for positions sourced from the same database and haven't seen this issue. I would check your assumptions:
Are you truncating your values over the wire?
Are you rounding the position values differently on the two platforms?
Check the values you are passing into Google Maps and MapKit by logging them and comparing.
You can see from the following screenshots that the same latitude/longitude are rendered on the same position on the map:
Update
I tried the coordinates you mentioned in the comments and got the same position for both. You need to check your assumptions. The values that you are using on the web or on the device are not the values you think they are: