How to manage map pins? iOS - ios

From the server response comes to me with an update of coordinates every 5 second. This coordinates I add to map like pins. But existing coordinates of current object not removes, it coordinates just add as new. How to update coordinates of current object and remove object that have no coordinates for now?
I use native map. If you give any simple I'll be happy
The response from the server, I receive the coordinates of users if the user is, if not - nothing comes. I need an approach without removing all the coordinates and with management (delete or update), depending on the receipt of a new member eoordinaty or delete it

Use this :
[mapView removeAnnotations:mapView.annotations]
Before adding your annotation.
Hope it works :)

Related

Turn off Openlayers 3 Geolocation

So, my idea of turning off the Geolocation functionality in an Openlayers 3.9.0 map is to have a toggle button that when is clicked it stops the tracking and removes the feature from the geolocation layer
geolocation.setTracking('false');
featuresOverlay.getSource().clear();
and then to turn it on again it turns the tracking on, adds a feature to the geolocation layer, sets its coordinates and re-centers the map
geolocation.setTracking('true');
featuresOverlay.getSource().addFeature(positionFeature);
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ? new ol.geom.Point(coordinates) : null);
view.setCenter(coordinates);
Well, this technically does not count as turning on/off the geolocation because it removes all the visual elements, it does not actually turns on/off the API. Is there such a possibility, or the above are enough?
Sure it does, after one minor change.
Assuming that geolocation in your code references an instance of ol.Geolocation, calling geolocation.setTracking(false) will make the geolocation call clearWatch on the browsers geolocation API. The relevant code is here.
However, setTracking expects a boolean value. You send the string 'false', which is interpreted as a truthy value (since it's a non-empty string). Remove the quotation marks from the setTracking paramters, and it should work as expected.

How to reload WMTS Tiles after progromattically changing the map center and zoom?

I'm implementing a feature for users to select a list item that corresponds to a point on the map. I am currently able to set the correct map center and the zoom level but the map tiles are blank until I cause a MouseWheelZoom interaction to occur on the map. How do I get my WMTS layers to update to the new zoom level and map extent?
In principle, changing the tileUrlFunction of a WMTS source will trigger a refresh, because that clears the tile cache. If you're lucky and your WMTS server makes proper use of Etags, just using the same url function again will work:
wmtsSource.setTileUrlFunction(wmtsSource.getTileUrlFunction());
If your WMTS server just sets expire headers, you'll have to append something to the url to force the browser to refetch it. Assuming you use KVP encoding to talk to your WMTS server, you could achieve this by doing something like
var random = Math.random();
var originalTileUrlFunction = wmtsSource.getTileUrlFunction();
wmtsSource.setTileUrlFunction(function() {
return originalTileUrlFunction.apply(this, arguments) + '&' + random;
});

Adding custom objects to a Parse backend iOS

I am building an application that stores locations in a list and later maps them.
The problem I'm running into is an inability to save MKMapItems to a Parse database. I need to save these MKMapItems because they are the only unique identifiers for locations on a map that would not require searching the map again (ex.location name, ex. address).
So my question is, how can I save an MKMapItem to a Parse database?
And to follow up, if it is not possible to save an MKMapItem, how else can I save these items to a map so that I do not have to re-search?
MKMapItem: https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapItem_class/Reference/Reference.html
Parse:
https://www.parse.com/docs/ios_guide#top/iOS
EDIT
Another detail that might help: I'm using this to store information about particular venues. For example restaurants. I don't necessarily want to be creating a new map annotations at that mark if I can avoid it.
I'm not sure if Parse has prebuilt support for it, but you can definitely create your own class to do it:
1) You can create an MKMapItem from an MKPlacemark, using this init method
- (id)initWithPlacemark:(MKPlacemark *)placemark
2) MKPlacemark is basically just a coordindate and address, created using this init method
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
CLLocationCoordinate2D can easily be stored in a custom class on Parse. If you care, you can also store the relevant address values too.
3) When you need to fetch MKMapItems, you actually fetch the underlying MKPlacemark coordinates, create MKPlacemarks, and finally create MKMapItems using each.

How to show multiple route IOS Mapview

I am creating IOS Application map based application in my app I like to show the route/path between source and destination and also I have done that but I will show only one route/path. I like to show all the possible path between the source and the destination like google map. To illustrate my idea I have added the screenshot I like to show path like this. Is there is any sample for this?
Thanks in advance
Follow these simple steps :
Get Two Input locations.
Use the method -geocodeAddressString: completionHandler: of Geo Coder class (from Core Location Framework) for getting the coordinates for the given location string.
Use MkPointAnnotation object for creating annotation on the locations in map.
Send request to the google API for getting the Direction between two locations.
As of the google API Response (Available in both JSON & XML) You would have overview_polyline object, which has the array of location coordinates. But they were encoded, you have to use the correct decoding module to get the latitude and longitude.
With the decoded location coordinates you can create the poly lines using MKPolyline instance method. MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:[overlayPoints count]]; [mapView addOverlay:polyLine];
Now the polyline have been drawn over the map still it will not be visible as the final go we have to override the -viewForOverlay method for displaying the poly line view.
If you still have any confusions then you can always check some Tutorials.

Is it possible to replace one marker using gmaps4rails?

Using Gmaps.map.replaceMarkers() I can replace entire marker set. But in my application I will use more than 3000 markers.
How to replace one marker or subset of markers?
This is definitely possible but because there is no rule, there is custom code to write.
Here is how I proceed generally:
I add some custom data in the marker's json, the id of the active record's object generally
I sort my markers client side in javascript variables, say you have the ids of markers you want to remove in a js array called toClear
I remove useless markers:
Coffeescript:
for marker in Gmaps.map.markers
if marker.id in toClear
Gmaps.map.clearMarker marker
I add the new one Gmaps.addMarkers new_markers_array

Resources