Forum Archive

Map API, need suggestions for how to execute ideas

RocketBlaster05

Hello! I figured I should make this a new post so more eyes can see it. I am attempting to modify the code of the default python 3 map API example from omz so that I can do the following:

I have a simple ui.load_view() I plan to make later which will ask the user if they want to mark their current location on the map. However I would need a button to be pressed for the user to get the view to work. Also, the user would need to be able to do so as many times as they like, so that multiple marks can appear on the map. The positions of the markers would need to be saved so that the next time the map is activated, the markers will reappear.

I understand this is likely a fair amount of code, but any help would be greatly appreciated. If you could suggest any ideas for me to test later I would be very thankful.

cvp

@RocketBlaster05 try this quick and dirty example.
Press the map button to show or hide the map
Long press add a new location, temporary as "dropped" then as "user point" at next long press.
Locations are saved in a file (here a.loc) and when you restart the script, previous points are shown on the map as green pin's, dropped is red.
Hoping this helps (only if I have correctly understood your request, maybe I could be wrong as usual šŸ¤”)
Edit: source has just been modified for pin's color

#!python2
'''
NOTE: This requires the latest beta of Pythonista 1.6 (build 160022)
Demo of a custom ui.View subclass that embeds a native map view using MapKit (via objc_util). Tap and hold the map to drop a pin.
The MapView class is designed to be reusable, but it doesn't implement *everything* you might need. I hope that the existing methods give you a basic idea of how to add new capabilities though. For reference, here's Apple's documentation about the underlying MKMapView class: http://developer.apple.com/library/ios/documentation/MapKit/reference/MKMapView_Class/index.html
If you make any changes to the OMMapViewDelegate class, you need to restart the app. Because this requires creating a new Objective-C class, the code can basically only run once per session (it's not safe to delete an Objective-C class at runtime as long as instances of the class potentially exist).
'''

from objc_util import *
import ast
import ctypes
import ui
import location
import os
import time
import weakref

MKPointAnnotation = ObjCClass('MKPointAnnotation')
MKPinAnnotationView = ObjCClass('MKPinAnnotationView')
UIColor = ObjCClass('UIColor') # used to set pin color

def mapView_viewForAnnotation_(self,cmd,mk_mapview,mk_annotation):
    global map_pin_type, map_pin_color, map_addr_color, map_pin_size, map_pin_radius, map_pin_borderwidth, map_pin_bordercolor, contacts_photos
    try:
        # not specially called in the same sequence as pins created
        # should have one MK(Pin)AnnotationView by type (ex: pin color)
        annotation = ObjCInstance(mk_annotation)
        mapView = ObjCInstance(mk_mapview)
        if annotation.isKindOfClass_(MKPointAnnotation):
            tit = str(annotation.title())
            subtit = str(annotation.subtitle())
            id = tit
            pinView = mapView.dequeueReusableAnnotationViewWithIdentifier_(id)          
            if not pinView:
                # Modify pin color: use MKPinAnnotationView
                pinView = MKPinAnnotationView.alloc().initWithAnnotation_reuseIdentifier_(annotation,id)
                pinView.canShowCallout = True   # tap-> show title
                pinView.animatesDrop   = True   # Animated pin falls like a drop
                if tit == 'Dropped Pin':
                    pinView.pinColor = 0 # 0=red 1=green 2=purple
                else:
                    pinView.pinColor = 1 # 0=red 1=green 2=purple
            else:
                pinView.annotation = annotation
            return pinView.ptr
        return None
    except Exception as e:
        print('Error on line {}'.format(sys.exc_info()[-1].tb_lineno), type(e).__name__, e)

# Build method of MKMapView Delegate
methods = [mapView_viewForAnnotation_]
protocols = ['MKMapViewDelegate']
try:
    MyMapViewDelegate = ObjCClass('MyMapViewDelegate')
except Exception as e:
    MyMapViewDelegate = create_objc_class('MyMapViewDelegate', methods=methods, protocols=protocols)    

# _map_delegate_cache is used to get a reference to the MapView from the (Objective-C) delegate callback. The keys are memory addresses of `OMMapViewDelegate` (Obj-C) objects, the values are `ObjCInstance` (Python) objects. This mapping is necessary because `ObjCInstance` doesn't guarantee that you get the same object every time when you instantiate it with a pointer (this may change in future betas). MapView stores a weak reference to itself in the specific `ObjCInstance` that it creates for its delegate.
_map_delegate_cache = weakref.WeakValueDictionary()

class CLLocationCoordinate2D (Structure):
    _fields_ = [('latitude', c_double), ('longitude', c_double)]
class MKCoordinateSpan (Structure):
    _fields_ = [('d_lat', c_double), ('d_lon', c_double)]
class MKCoordinateRegion (Structure):
    _fields_ = [('center', CLLocationCoordinate2D), ('span', MKCoordinateSpan)]

class MapView (ui.View):
    @on_main_thread
    def __init__(self, *args, **kwargs):
        ui.View.__init__(self, *args, **kwargs)
        MKMapView = ObjCClass('MKMapView')


        frame = CGRect(CGPoint(0, 0), CGSize(self.width, self.height))
        self.mk_map_view = MKMapView.alloc().initWithFrame_(frame)
        #print(dir(self.mk_map_view.region()))
        flex_width, flex_height = (1<<1), (1<<4)
        self.mk_map_view.setAutoresizingMask_(flex_width|flex_height)
        self_objc = ObjCInstance(self)
        self_objc.addSubview_(self.mk_map_view)
        self.mk_map_view.release()
        self.long_press_action = None
        self.scroll_action = None
        #NOTE: The button is only used as a convenient action target for the gesture recognizer. While this isn't documented, the underlying UIButton object has an `-invokeAction:` method that takes care of calling the associated Python action.
        self.gesture_recognizer_target = ui.Button()
        self.gesture_recognizer_target.action = self.long_press
        UILongPressGestureRecognizer = ObjCClass('UILongPressGestureRecognizer')
        self.recognizer = UILongPressGestureRecognizer.alloc().initWithTarget_action_(self.gesture_recognizer_target, sel('invokeAction:')).autorelease()
        self.mk_map_view.addGestureRecognizer_(self.recognizer)
        self.long_press_location = ui.Point(0, 0)
        self.map_delegate = MyMapViewDelegate.alloc().init()#.autorelease()
        self.mk_map_view.setDelegate_(self.map_delegate)
        self.map_delegate.map_view_ref = weakref.ref(self)
        _map_delegate_cache[self.map_delegate.ptr] = self.map_delegate

    def long_press(self, sender):
        #NOTE: The `sender` argument will always be the dummy ui.Button that's used as the gesture recognizer's target, just ignore it...
        gesture_state = self.recognizer.state()
        if gesture_state == 1 and callable(self.long_press_action):
            loc = self.recognizer.locationInView_(self.mk_map_view)
            self.long_press_location = ui.Point(loc.x, loc.y)
            self.long_press_action(self)

    @on_main_thread
    def add_pin(self, lat, lon, title, subtitle=None, select=False):
        '''Add a pin annotation to the map'''
        MKPointAnnotation = ObjCClass('MKPointAnnotation')
        coord = CLLocationCoordinate2D(lat, lon)
        annotation = MKPointAnnotation.alloc().init().autorelease()
        annotation.setTitle_(title)
        if subtitle:
            annotation.setSubtitle_(subtitle)
        annotation.setCoordinate_(coord, restype=None, argtypes=[CLLocationCoordinate2D])
        self.mk_map_view.addAnnotation_(annotation)
        if select:
            self.mk_map_view.selectAnnotation_animated_(annotation, True)

    @on_main_thread
    def remove_all_pins(self):
        '''Remove all annotations (pins) from the map'''
        self.mk_map_view.removeAnnotations_(self.mk_map_view.annotations())

    @on_main_thread
    def set_region(self, lat, lon, d_lat, d_lon, animated=False):
        '''Set latitude/longitude of the view's center and the zoom level (specified implicitly as a latitude/longitude delta)'''
        region = MKCoordinateRegion(CLLocationCoordinate2D(lat, lon), MKCoordinateSpan(d_lat, d_lon))
        self.mk_map_view.setRegion_animated_(region, animated, restype=None, argtypes=[MKCoordinateRegion, c_bool])

    @on_main_thread
    def set_center_coordinate(self, lat, lon, animated=False):
        '''Set latitude/longitude without changing the zoom level'''
        coordinate = CLLocationCoordinate2D(lat, lon)
        self.mk_map_view.setCenterCoordinate_animated_(coordinate, animated, restype=None, argtypes=[CLLocationCoordinate2D, c_bool])

    @on_main_thread
    def get_center_coordinate(self):
        '''Return the current center coordinate as a (latitude, longitude) tuple'''
        coordinate = self.mk_map_view.centerCoordinate(restype=CLLocationCoordinate2D, argtypes=[])
        return coordinate.latitude, coordinate.longitude

    @on_main_thread
    def point_to_coordinate(self, point):
        '''Convert from a point in the view (e.g. touch location) to a latitude/longitude'''
        coordinate = self.mk_map_view.convertPoint_toCoordinateFromView_(CGPoint(*point), self._objc_ptr, restype=CLLocationCoordinate2D, argtypes=[CGPoint, c_void_p])
        return coordinate.latitude, coordinate.longitude

    def _notify_region_changed(self):
        if callable(self.scroll_action):
            self.scroll_action(self)


# --------------------------------------
# DEMO:

def long_press_action(sender):
    global locs,path
    # Add a pin when the MapView recognizes a long-press
    c = sender.point_to_coordinate(sender.long_press_location)
    # this of only to special process asked in forum
    # https://forum.omz-software.com/topic/7077/removing-custom-pins-with-map-api
    for annotation in sender.mk_map_view.annotations():
        if str(annotation.title()) == 'Dropped Pin':
            sender.mk_map_view.removeAnnotation_(annotation)
            prev_lat,prev_lon = locs[-1]
            sender.add_pin(prev_lat, prev_lon, 'user point', str((prev_lat, prev_lon)))
    else:
        sender.add_pin(c[0], c[1], 'Dropped Pin', str(c), select=True)
    sender.set_center_coordinate(c[0], c[1], animated=True)
    locs.append(c)
    with open(path,mode='wt') as f:
        content = str(locs)
        f.write(content)

def scroll_action(sender):
    # Show the current center coordinate in the title bar after the map is scrolled/zoomed:
    sender.name = 'lat/long: %.2f, %.2f' % sender.get_center_coordinate()

def main():
    global locs,path
    # create main view
    mv = ui.View()
    mv.name = 'Map for RocketBlaster05'
    mv.background_color = 'white'
    mv.present('fullscreen')
    w,h = ui.get_screen_size()
    # Create and present a MapView:
    v = MapView(frame=(0,0,w,h-76))
    v.hidden = True
    mv.add_subview(v)
    bmap = ui.ButtonItem()
    bmap.image = ui.Image.named('iob:map_32')
    mv.right_button_items = (bmap,)
    def bmap_action(sender):
        v.hidden = not v.hidden
    bmap.action = bmap_action
    v.long_press_action = long_press_action
    v.scroll_action = scroll_action
    path = 'a.loc'
    if not os.path.exists(path):
        locs = []
    else:
        with open(path,mode='rt') as f:
            content = f.read()
            locs = ast.literal_eval(content)
            for lat,lon in locs:
                v.add_pin(lat, lon, 'user point', str((lat, lon)))

if __name__ == '__main__':
    main()
RocketBlaster05

@cvp Yes this is very helpful. I will need to adjust the button function but that is really easy, and I'll change the presentation to "sheet". I will need to modify the code so that it automatically gets centered on the user's location like omz's second version of the map. If you could guide me towards how to do that, that would be amazing.

cvp

@RocketBlaster05 That will not be for today...sorry
Don't you want to center the map on the center of all previous pin's?

cvp

@RocketBlaster05 did you try several runs with multiple pin's, like

ccc

!python2 ??

cvp

@ccc old line of omz

cvp

@ccc works without the line

cvp

@ccc you know my standard response to your advices: you're always right šŸ˜‡

cvp

@RocketBlaster05 said:

automatically gets centered on the user's location

def main():
    .
    .
    .
    # center on user location               
    import location
    location.start_updates()
    time.sleep(1)
    loc = location.get_location()
    location.stop_updates()
    if loc:
        lat, lon = loc['latitude'], loc['longitude']
        v.set_region(lat, lon, 0.05, 0.05, animated=True)

if __name__ == '__main__':
    main()

Next lesson : zoom so all previous pin's are visible, interested?

RocketBlaster05

@cvp yes! that would be very helpful. I am very thankful you are willing to help out!

cvp

@RocketBlaster05

def compute_region_param(l):
    # Compute min and max of latitude and longitude
    min_lat = min(l,key = lambda x:x[0])[0]
    max_lat = max(l,key = lambda x:x[0])[0]
    min_lon = min(l,key = lambda x:x[1])[1]
    max_lon = max(l,key = lambda x:x[1])[1]
    d_lat = 1.2*(max_lat-min_lat)
    d_lon = 1.2*(max_lon-min_lon)
    return min_lat,min_lon,max_lat,max_lon,d_lat,d_lon

def main():
    .
    .
    .
    # center on user location               
    import location
    location.start_updates()
    time.sleep(1)
    loc = location.get_location()
    location.stop_updates()
    if loc:
        lat, lon = loc['latitude'], loc['longitude']
        if locs:
            min_lat,min_lon,max_lat,max_lon,d_lat,d_lon = compute_region_param(locs)
            v.set_region((min_lat+max_lat)/2, (min_lon+max_lon)/2,1.2*(max_lat-min_lat), 1.2*(max_lon-min_lon), animated=True)  
        else:
            v.set_region(lat, lon, 0.05, 0.05, animated=True)

RocketBlaster05

@cvp this is very good. One more thing for now: I want to make the user's location the purple pin instead of the green/red so that it stands out. I have the location as 'Current Location' for the pin. Any ideas? Thanks

cvp

@RocketBlaster05 said:

user's location the purple pin

Be careful: if you change something in the mapView_viewForAnnotation_ def, you need to restart Pythonista because the class is already built and kept in memory (restart means remove it from the tasks list and relaunch it)

Did you remark that if you tap on a pin, you get its title and location.

Ɖdit: try to avoid to have in the .loc file a point with the same coordinates as the user location,
because you could have a purple and a green pin at exactly same position and only see one, even with a big zoom.

def mapView_viewForAnnotation_(self,cmd,mk_mapview,mk_annotation):
    .
    .
    .
                if tit == 'Dropped Pin':
                    pinView.pinColor = 0 # 0=red 1=green 2=purple
                elif tit == 'Current Location':
                    pinView.pinColor = 2 # 0=red 1=green 2=purple
                else:
                    pinView.pinColor = 1 # 0=red 1=green 2=purple
.
.
.
    loc = location.get_location()
    location.stop_updates()
    if loc:
        lat, lon = loc['latitude'], loc['longitude']
        # add a purple pin for user's location
        v.add_pin(lat, lon, 'Current Location', str((lat, lon)))
        # don't save it in file but add it in locs for centering zoom
        locs.append((lat,lon))
        if locs:
            min_lat,min_lon,max_lat,max_lon,d_lat,d_lon = compute_region_param(locs)
            v.set_region((min_lat+max_lat)/2, (min_lon+max_lon)/2,1.2*(max_lat-min_lat), 1.2*(max_lon-min_lon), animated=True)  
        else:
            v.set_region(lat, lon, 0.05, 0.05, animated=True)

ccc
pin_colors = {
    "Dropped Pin": 0,  # red
    "Current Location": 2,  # purple
}
…
pin_color = pin_colors.get(title, 1)  # default to green
cvp

@ccc said:

pin_color = pin_colors.get(title, 1) # default to green

pinView.pin_color = pin_colors.get(tit, 1)  # default to green
cvp

@RocketBlaster05 and tell me if you want to see your own photo instead of a purple pin

cvp

@RocketBlaster05 or, if you prefer,

Or, with with some drops of blood šŸ˜‚

cvp

@RocketBlaster05 and if you want to be able to set view type (satellite, flyover...), you can find this here

See two buttons above right of the map

RocketBlaster05

@cvp said:

@RocketBlaster05 and tell me if you want to see your own photo instead of a purple pin

This is a great idea. I would like to incorporate this to make the map feel more personal. This may be a big request but can you also show me how to go about making the map start automatically instead of having to press the button? I would like to make it so the button will mark somebody’s location with an image of like a trash bag. Also, is there a simple command I can use to make the map update somebody’s position? I haven’t tried moving around with the map open so if it already moves automatically then that’s my bad for not checking. Thanks in advance.

I would like for it to show the face on a little pin, like you showed with the blood. I would like for the memoji to be able to have the trash bag I mentioned before just below it like the blood drop. If that is possible, that would be exactly what I need for my pins.

ccc

An image of like a trash bag… šŸš®šŸ—‘ā™»ļøā˜ ļøšŸ¤¢šŸ’°šŸ’©šŸ¤®

cvp

@RocketBlaster05

First of all, as we live in different time zones, dialog is not easy and thus there will be a delay, sometimes big, between questions and answers, in both directions.
Secondly, as the script becomes bigger and bigger, I had put it in Github, are you used to download it from Github or do you prefer that I always paste it in the forum topic. If a modification is little, I can paste the modified part only, but if it is long, or in different parts of the script, I would need to paste the entire script every time...
Your last post contains several requests, thus I have several questions, could you, please, answer to each of them. I number them so you can only answer by 'n°:answer'.
1) do you want the two buttons 3D and MapType and their process?
2) do you want a photo/emoji instead of the purple pin of your own location?
3) map will be visible automatically if you remove the line "v.hidden = True" in the main.
4) replace the map button by another icon and process is easy but I need to know exactly which process. The only problem is to identify which pin...

This is how I've modified the script in Github, please try it:

  • no more map button
  • no trash button, but:
    • when you tap on a pin, you see a trash button
    • if you tap it, the green pin is replaced by a trash on a little pin
      But the file would not be modified, thus, at next run, you would see your pin's back.
      Perhaps should be better to entirely remove the location without any trash pin but it is your script thus you have to decide the process you want.

Where to tap to delete

Result

cvp

@ccc said:

An image of like a trash bag… šŸš®šŸ—‘ā™»ļøā˜ ļøšŸ¤¢šŸ’°šŸ’©šŸ¤®

Why doesšŸ’°represent trash? I agree to get your trashes šŸ˜‚

RocketBlaster05

@cvp github or the forum here is fine. Whatever is easier for you. The github example you provided is excellent.
1. Yes, the map type buttons have some helpful implications and I like having it as an option in the program.
2. Yes, I want the emoji instead of the purple pin as it is makes more sense for the user.
3. I love that the map opens on its own
4. Yes. I want the button to make it so that when the user presses it, it will present a ui.load_view(). From there, the ui.load_view() will ask if the user wants to mark their location with trash (where they are currently located). If they say yes, their location will be marked with the trash symbol. I would like to make it so that if the user marks their location with a trash symbol, that location will be saved onto the loc file for the next time the map is opened.

P.S. does the map update the user's position automatically or do I need to input code to make that occur?

Thanks so much!

cvp

@RocketBlaster05 said:

does the map update the user's position automatically or do I need to input code to make that occur?

I don't understand that.
But first, did you try the way I set as trash.
If you have gƩnƩral button to ask something to the user, you would need to also choose the pin.
Anyway, do you need that I do something more?

cvp

@RocketBlaster05 said:

I would like to make it so that if the user marks their location with a trash symbol, that location will be saved onto the loc file for the next time the map is opened.

It should be possible, when you set a location as trash, to add a line in the file with this location and a flag "trash".
And when you start the script, it checks for ea h location if it is trashed and set a trash pin.
Do you want I program that?

RocketBlaster05

@cvp For example, if somebody were to drive for about a mile with the map open, will their marker move with them or does it stay still?

And yes, I used the trash icons. I would like that process to be applied to the user's location through the button I mentioned earlier. However, to make it more simple maybe, could it just drop another pin on the person's location?
For example: The person's emoji is moving across the map, and then they mark their location with the unique trash pin. Their emoji will not get replaced by the trash pin but will just give it a location to be dropped on. Please tell me if I need to explain anything better.

Thanks!

RocketBlaster05

@cvp said:

It should be possible, when you set a location as trash, to add a line in the file with this location and a flag "trash".
And when you start the script, it checks for ea h location if it is trashed and set a trash pin.
Do you want I program that?

Yes, that is exactly what I am looking for.

cvp

@RocketBlaster05 said:

if somebody were to drive for about a mile with the map open, will their marker move with them or does it stay still?

No, pin's location do not move. In the file, their last,Lon are saved and used as is

cvp

@RocketBlaster05 said:

Yes, that is exactly what I am looking for.

This is done, GitHub updated, try it: set a pin as trash, rerun script and see

cvp

@RocketBlaster05 said:

I would like that process to be applied to the user's location through the button I mentioned earlier. However, to make it more simple maybe, could it just drop another pin on the person's location?
For example: The person's emoji is moving across the map, and then they mark their location with the unique trash pin. Their emoji will not get replaced by the trash pin but will just give it a location to be dropped on. Please tell me if I need to explain anything better.

Not yet understood, sorry

cvp

@RocketBlaster05 actually, my script foresees 4 types of pin:
- dropped pin red, becomes green at next dropped, no button accessible when you tap the pin
- user point Green, trash button accessible when you tap the pin
- trash pin, no button accessible when you tap the pin
- person emoji pin for current location, no button accessible when you tap the pin

Do you want to change something?

RocketBlaster05

@cvp Could you make it so that the trash button is accessible when you tap the emoji pin? But instead of changing the emoji to trash, could it drop a trash pin onto the map? The location of the trash pin would need to be saved. Thanks!

RocketBlaster05

@cvp said:

This is done, GitHub updated, try it: set a pin as trash, rerun script and see

Maybe I missed something, but the trash pins do not seem to be saved when I rerun the map...

cvp

@RocketBlaster05 said:

Could you make it so that the trash button is accessible when you tap the emoji pin? But instead of changing the emoji to trash, could it drop a trash pin onto the map? The location of the trash pin would need to be saved. Thanks!

I'll do it but no time immediately, in some hours.

A little correction: the emoji pin is not saved in the file actually, it is set at each run in function of real location.
That will say that if you close the program, move in an another location and restart the script, you will not see anymore your previous location.

cvp

@RocketBlaster05 said:

Maybe I missed something, but the trash pins do not seem to be saved when I rerun the map...

Did your re-download the script? It has been updated some minutes ago.

RocketBlaster05

@cvp I'll give it another shot. Take as much time as you need, I understand this might be a lot to work on and I feel bad for having you do so much. Thank you so much for all this effort you've put in so far.

RocketBlaster05

@cvp said:

Did your re-download the script? It has been updated some minutes ago.

I reset the loc file and had the program create a new one... same issue. Let me make sure I am doing this right: I tap a green pin, make it trash, then close the map using the X in the top left. Anything I'm doing wrong?

cvp

@RocketBlaster05 said:

I reset the loc file and had the program create a new one... same issue. Let me make sure I am doing this right: I tap a green pin, make it trash, then close the map using the X in the top left. Anything I'm doing wrong?

No, you're right, obviously a bug, sorry, I'll correct it but not immediately, sincerely sorry.

cvp

@RocketBlaster05 could you download the GitHub version and retry.
You could even have the trash button for the face pin and if you tap it, add a trash pin normally stored in the file.
Please test and tell me what

RocketBlaster05

@cvp I tested the code and it works great. Only suggestion I have is to ask if it is possible to make the trash icon drop a new pin instead of changing the image of the old pin.

So when they press the trash icon, it drops a new pin with the trash symbol. I want the emoji pin to still exist. Other than that, everything works great.

cvp

@RocketBlaster05 said:

So when they press the trash icon, it drops a new pin with the trash symbol. I want the emoji pin to still exist. Other than that, everything works great.

Do you ask that only for the Current location face pin or for all green pin's also?

Ɖdit: or I didn't understand, as usual.

RocketBlaster05

@cvp
Only the current location pin

cvp

@RocketBlaster05 Ok, I'll do it, but that will say that two pin's will have same location and that one may hide the other.

You will have something like this if the transparent trash is in front

But if the non transparent face is in front, you would not see the trash

And perhaps you know that current location is not always exactly the same even if you don't move.
That will say that if you zoom at maximum, you would see the trash and the face not exactly at same x,y

Thus, please confirm.

RocketBlaster05

@cvp this will be fine. I just need the location to be marked. If it’s off by .00000001 it is not an issue. The goal is that people will be able to walk around and get close to the trash icon.
Also, for the idea above to work I would need the map to update the user’s position constantly . Is this possible? Thanks

cvp

@RocketBlaster05 said:

I would need the map to update the user’s position constantly

One more time, I don't understand šŸ¤”

Ɖdit: or do you want that when you keep the script running and the map displayed, if you move with your iDevice in your hands, the face pin also moves?

cvp

@RocketBlaster05 GitHub version updated: tap trash for face pin will now add a trsh pin while keeping also the face pin.

cvp

@RocketBlaster05 Github updated to modify face pin location every 10 seconds (hoping it will work šŸ˜‚)

Test it by moving your iDevice (in your room/garden/street in function of your house size) with script running and map displayed, with maximum zoom

nb: I am surprised myself of my code

RocketBlaster05

@cvp it seems to be tracking me pretty well. I do not know the limits of the code but is it just a simple fix to make it about every 2 seconds? to more accurately cover somebody walking versus driving? Thanks

cvp

@RocketBlaster05 GitHub ok for 2 seconds

RocketBlaster05

@cvp and while testing it at school several pins popped up. I am back home now and the map was zooming in on the cluster of pins rather than the face (the face is not even in the region shown). Any idea what might be causing this? Thanks

cvp

@RocketBlaster05 said:

the face is not even in the region shown

Yes, it works so, rƩgion of zoom does not include user location. Do you want it includes it?

RocketBlaster05

@cvp said:

@RocketBlaster05 GitHub ok for 2 seconds

ah there is an issue with this... I assume there is a time.sleep() somewhere in the code when the update is called, because every couple of seconds it freezes for about 1 second. I do not know how vital or where the time.sleep() is.

Edit: I removed the time.sleep() causing the issue and seemingly nothing is wrong with the code...

cvp

@RocketBlaster05 said:

removed the time.sleep()

Ok but the time.sleep was needed in the past to let the location start doing its job...

RocketBlaster05

@cvp I have run it a couple times to test it and it still looks fairly smooth, I do not see anything wrong with it.

cvp

@RocketBlaster05 in my code, I'll let it with sleep(0.1) by security

RocketBlaster05

@cvp said:

Yes, it works so, rƩgion of zoom does not include user location. Do you want it includes it?

I forgot to tell you, sorry, that I have realized that including all the pins on start will cause some issues... I would rather it just center on the face. Sorry for the inconvenience

Also, the trash pin on the face removes the face... Is it meant to do so? Thanks

cvp

@RocketBlaster05 GitHub updated with "at start zoom on region including all pin's and user location"

cvp

@RocketBlaster05 said:

I forgot to tell you, sorry, that I have realized that including all the pins on start will cause some issues... I would rather it just center on the face. Sorry for the inconvenience

I had just updated in another way....before reading this post,

Ok, I'll modify but if I center on user location, at which scale? Including what?

Or I zoom like if no pin, like the first run

RocketBlaster05

@cvp The zoom should just be within maybe just a couple blocks, nothing too large. I want the user to be able to see a couple of nearby roads like if they were in a neighborhood.

cvp

@RocketBlaster05 said:

the trash pin on the face removes the face... Is it meant to do so?

This bug will be for tomorrow...

cvp

@RocketBlaster05 said:

The zoom should just be within maybe just a couple blocks, nothing too large. I want the user to be able to see a couple of nearby roads like if they were in a neighborhood.

GitHub updated

RocketBlaster05

@cvp said:

This bug will be for tomorrow...

No worries. I'm sure it's pretty late near you now. I have a couple weeks to make sure everything is nice and smooth, so believe me there's no rush for anything here. I still can't say how much I appreciate what you're doing here... saving me so much time... thank you.

cvp

@RocketBlaster05 my pleasure

cvp

@RocketBlaster05 said:

I'm sure it's pretty late near you now.

Yes, and I' so old...

cvp

@RocketBlaster05 I've to add that I don't like the look of the .loc file, I want to change it so it could contain all what we need but in a better way. I hope that I'll find the time to do it.

RocketBlaster05

@cvp just a note: since the current location is replaced with a trash, It is causing there to be "too many values to unpack" on line 281. I assume this is due to the nature of the other pins.

I'll check in again tomorrow. Thanks.

Edit: In regards to the message below: Yes in your github script. It occurs after you mark the person's location as trash and then attempt to place a second red pin on the map.

cvp

@RocketBlaster05 said:

on line 281

In my script?

RocketBlaster05

@cvp to clarify what I said above:

Here is the order that causes the issue:
1. Place a red pin
2. Mark user location as trash
3. Attempt to place another red pin

cvp

@RocketBlaster05 thanks to identify "how to generate the bug", I'll check it tomorrow in my afternoon, not before, sorry

RocketBlaster05

@cvp all good. see you tomorrow.

cvp

@RocketBlaster05 the problem occurs even if the pin to trash is a green, not only the user pin.
Red/trash/red
Identified, correction tomorrow

cvp

@RocketBlaster05 GitHub corrected for crash "red, set trash user or green, red"

cvp

@RocketBlaster05 Github corrected for bug "the trash pin on the face removes the face... Is it meant to do so?"

RocketBlaster05

@cvp Code works great! For the time being I need to test the accuracy of the pins dropped on the person’s location, so I commented all of the long press function and just had it pass. No errors so that’s good.

Whenever you get the time, could you show me how to make it so that the map type button only allows you to use ā€œhybridā€ or ā€œstandardā€? Thanks

cvp

@RocketBlaster05 GitHub updated, or

    def maptype_button_action(self,sender):
        x = self.x + sender.x + sender.width/2
        y = 70 + self.y + sender.y + sender.height
        sub_menu_dict = {'standard':0, 'hybrid':2}
        #sub_menu_dict = {'standard':0, 'satellite':1, 'hybrid':2, 'satelliteFlyover':3, 'hybridFlyover':4, 'mutedStandard':5}
        sub_menu = []
        for k in [*sub_menu_dict]:
            sub_menu.append(k)
        tv = ui.TableView()
        tv.frame = (0,0,180,85)
        #tv.frame = (0,0,180,280)
RocketBlaster05

@cvp hm.... got the new github code and it’s causing the iPad to crash... only happened after the map type change.

I've done some poking around... I have an old version of the map saved which runs with no issues. If I run the github version, it causes the iPad to crash. However, if I run the old version of the map first, then run the github version, the github version runs fine. This doesn't make any sense to me but I'm looking for any reason as to why this is happening.

RocketBlaster05

@cvp Also, when the code is shortened to just 'standard':0 and 'hybrid':2, when the user selects hybrid it actually shows the 'satellite' view...

cvp

@RocketBlaster05 sorry for these bugs, GitHub corrected

RocketBlaster05

@cvp works great!

cvp

@RocketBlaster05 šŸ˜… ready for next request....

RocketBlaster05

@cvp won’t be anything for a couple days. Got some data to collect. Hope you find some other fun codes to do in the meantime! Thanks as always

RocketBlaster05

@cvp sorry been busy so testing has been an issue. Finally got around to it. My iPad doesn’t have an automatic connection (needs WiFi) but it is still able to give locations on the map. I brought a WiFi hotspot with me and it didn’t seem to help. The locations are mostly accurate, but the updating is extremely inconsistent.
I had the update_interval set to values like 0.2, 0.5, 2, 5, and 10. None of them updated on their set intervals. Do you know if this is due to the lack of connection on my iPad or maybe something else is causing the error?
Thanks!

cvp

@RocketBlaster05 don't forget that an iPad without cellular does not have any gps, thus the only location you can get is approximately this one of the router, based on known (by Apple) wifi networks. If you have an iPhone, try with it.

RocketBlaster05

@cvp alright. I transferred my files to my iPhone and the tracking works much better. Not sure if this is because of the code or the map API but the app cannot track the person while moving at a speed beyond walking.
The Map only updated when coming to stops, and often times the map would not update after coming to a stop. I would have to reopen the map for it to begin trying to update again.
If you have any ideas I’ll be glad to hear them!

Thanks as always!

cvp

@RocketBlaster05 no idea. Perhaps too much updates asked. Increase interval?

RocketBlaster05

@cvp welp. Looks like I need some more improvements because the other information didn't count as data.

This might be the roughest task I've asked of you, but here it is:

I need to be able to triangulate the center of various pins. For example, if there is like 4 pins in a 10 meter area, I need to be able to drop a new pin in the center of all of those pins (to get a more centered marker). Of course, that new pin would need a new picture and its location would need to be saved... If you can use a custom image that would be great, as I've been looking through emoji's and none of them really are like a crosshair or a center "mark" if that makes sense. If a custom image is not possible, there is a recycle emoji that I would prefer as the next best choice.

I'm sorry for dumping all this on you but I have no clue how to do this... if you need any clarification just ask.

Thanks as always!

cvp

@RocketBlaster05
1) how do you choose the pin's group for which you need to compute the center?

2) Or do you want the center of all green pin's?
And if you add a supplementary green pin, do you want the center to move automatically ?

3) what is customized image? A photo or something I would have to draw?

RocketBlaster05

@RocketBlaster05 said:

I need to be able to triangulate the center of various pins.

I have found a fairly simple looking code to address this, which can be found here: https://www.101computing.net/cell-phone-trilateration-algorithm/
The issue I have now is implementing the stored coordinates into this algorithm. I basically want to make it so that if there are three pins specifically in a close location, then it would combine them into one point using the algorithm above.

@cvp
1. Only three pins at once should be combined, and only those in a close proximity.
2. New pins should not affect the location, as once the new center pin is made, I wish that the three trash pins are removed.
3. Maybe not drawn, but just an image off the internet of like a crosshair or center mark.

cvp

@RocketBlaster05 sorry, I'm not sure to understand correctly.

Suppose we have 20 green pin's. Which pin's have to be, let us say, centered?
What is "close"? Which is the distance?

The triangulation you gave does not work here, you don't have radious of antennas.

RocketBlaster05

@cvp I'd prefer a distance of 10 meters

cvp

@RocketBlaster05 Thus, I begin with pin 1, if I find some pin's at less of 10 meters, I search their center and I replace them by a cross-hair, which I save in the file and I remove the original pin's.
Then, I continue with a pin which was at more than 10 meters... correct?

RocketBlaster05

@cvp exactly.

cvp

@RocketBlaster05 but you have to know that the result would not be the same if I did begin with another pin than pin 1

cvp

Assume you have some green pin's, how do you want to start this process? A button?

RocketBlaster05

@cvp I more so wish for the process to be automatic. Also, it should combine the trash pins, not the green pins. The goal is that there will never be more than 3 trash pins in close proximity to one another, so the results should not change much when it comes to getting the center.

cvp

@RocketBlaster05 understood. I would need perhaps some hours for that, ready to wait?

RocketBlaster05

@cvp as long as you need my man. I got about a week and a couple days to get this done so if you need some extra time it is there. I'll check back every couple hours to see if you have any questions.

Thank you so much!

RocketBlaster05

@cvp actually sorry forgot to mention: I need all three trash pins to be present so I can record their locations. I would ask that you write the script as we just discussed, but show me where I would comment out the code to prevent the three pins from getting removed. Sorry for the inconvenience.

cvp

@RocketBlaster05 said:

show me where I would comment out the code to prevent the three pins from getting removed

We will see later... First, lines to be removed have to be written šŸ¤”

RocketBlaster05

@cvp all good. Just wanted to make sure you knew for later

What you wrote below sounds good.

cvp

@RocketBlaster05 said:

so I can record their locations

I could, for instance, store their locations in the cross-hair subtitle, thus you would see them when tapping the cross-hair, but ok, that's for the future.

cvp

@RocketBlaster05 for info, I'll use Haversine formula to compute the distance between two points of the earth.

RocketBlaster05

@cvp šŸ‘ sounds good

cvp

@RocketBlaster05 do you want this as cross-hair, or only the "plus" without the foot?

cvp

@RocketBlaster05 I want to take advantage of this big modification to change entirely the file layout to be able to save their:
- green
- trash
- cross-hair
But that would say that you would loose all of your actual data.
Ok with that?

RocketBlaster05

@cvp as in the locations already saved in the a.loc file? If so then yes. I can always just plot more points
P.S. could you find a cross with a circle around it

RocketBlaster05

@cvp The crosshair should stay by itself. I think it might be misleading if it was on a pin

cvp

@RocketBlaster05 which time is it for you and until when are you free for questions?

RocketBlaster05

@cvp sorry was busy. It’s 11:11 am for me and I can talk really for another 11 hours

cvp

@RocketBlaster05 something like, or do you prefer black

RocketBlaster05

@cvp that looks great

cvp

@RocketBlaster05 do you prefer that the file stays named a.loc or something .txt so you can edit it more easily in Pythonista. Please, let me know which name you want.

RocketBlaster05

@cvp a.loc is still editable in Pythonista but it would probably be easier to have it set to like locations.txt
Thanks

cvp

@RocketBlaster05 you will see in the script that, at begin, there are 3 parameters

radius         = 6371000    # earth radius in meters
close_distance = 10             # maximum 10 meters between 2 close pin's
close_number   = 3              # minimum pin's number to set as a close area

The checking of a close area needs to have at least 3 pin's with a maximum distance of 10 meters to the first one. That will say that
p2 <-- 10m --> p1 <-- 10m --> p3 is a close area even if p2 and p3 are distant or 20m
If you want another criteria tell me.
I could check if all points of a group are less distant of 10m, pair by pair.
More complex process but you can already test the script about graphic, file etc...

As soon I receive the name of the file like you prefer, I'll post the file in GitHub

cvp

@RocketBlaster05 Github done
Please, test it and tell me what.

RocketBlaster05

@cvp did some testing.

When green pins are converted into trash, they all combine seamlessly.

However, if I create a trash pin using the user location with the man emoji, it gives me an error on line 91... doesn’t properly delete the pins for some reason.

cvp

@RocketBlaster05 said:

However, if I create a trash pin using the user location with the man emoji, it gives me an error on line 91... doesn’t properly delete the pins for some reason.

I'll check. Be sure I did not test all... sorry but it is always so.

I'll also modify so a group has all their pin's at maximum distance each of other

cvp

@RocketBlaster05 Github updated

cvp

@RocketBlaster05
@cvp said:

I'll also modify so a group has all their pin's at maximum distance each of other

Done but not easy to test

RocketBlaster05

@cvp tested it... problem mentioned above is fixed. However if all three pins are created from the user’s location with the man emoji then the same issue occurs.

Thanks

cvp

@RocketBlaster05 said:

However if all three pins are created from the user’s location with the man emoji then the same issue occurs.

🄲 No more time today, sorry, but you have already enough to play/test.
Promised for tomorrow.

RocketBlaster05

@cvp Okay, I've narrowed down the issue: It seems to only occur if two pins have the same location as one another. Realistically, this would not be an issue, as the gps would most likely update before the person tries to mark another location. However, if somebody were to accidentally mark themselves twice, then this issue still persists. Perhaps there is a way to recognize if a location is already marked, and if so then a new point can't be created on the exact point. Not sure if this would interfere with the process for marking someone's location or not.

If this is possible, I wish that the error message would just be printed in console. From there I could edit it to make a popup occur saying (invalid location) or something of the sort.

Just some thoughts for when you get around to it.

Thanks as always

cvp

@RocketBlaster05 tomorrow, if my wife let me some free time šŸ™„

Ɖdit: I need to first correctly understand the bug before to be able to correct it.

cvp

@RocketBlaster05 said:

there is a way to recognize if a location is already marked, and if so then a new point can't be created on the exact point.

Done ( Github updated) you would get a console.alert message (up to you to put your own text).
I've seen it once but not easy to reproduce (thus to test) because it depends on the current location...

Do you know that I could easily make the circle of the crosshairs variable in function of the number of pin's they represent, or even display at center of the crosshairs the number of pin's they represent.
Ask if you want.

And I'm almost sure that your next request would be that if a pin just trashed is close to a crosshair area, this pin would be automatically included in this area if the pin is at good distance of each of area's points.
Am I wrong? Even if this process is not so easy. šŸ˜€

RocketBlaster05

@cvp said

Do you know that I could easily make the circle of the crosshairs variable in function of the number of pin's they represent, or even display at center of the crosshairs the number of pin's they represent.
Ask if you want.

Can you explain this a little more? As in the crosshairs would get larger the more pins are nearby? Because if so, that would be great. If this is what you are talking about, then I would prefer if it said on the crosshairs how many pins were combined (not coordinates but rather whole numbers)

And I'm almost sure that your next request would be that if a pin just trashed is close to a crosshair area, this pin would be automatically included in this area if the pin is at good distance of each of area's points.
Am I wrong? Even if this process is not so easy. šŸ˜€

I’m assuming this would be necessary for what was said above, so, yes that was my next plan lol

cvp

@RocketBlaster05 said:

I would prefer if it said on the crosshairs how many pins were combined (not coordinates but rather whole numbers)

That is what I wanted to say 🄲 in my poor English.

cvp

@RocketBlaster05 said:

yes that was my next plan lol

Obviously, not for today because, for me, not so easy, but promised

RocketBlaster05

@cvp but what do you mean by variable function? Does it change color, size, etc?

cvp

@RocketBlaster05 said:

variable function?

Not variable function but variable in function.
If the group contains 3 pin's: small diameter, if it contains 10: big diameter.
But if the drawing contains the number of pin's, this varying diameter is not needed.

cvp

@RocketBlaster05 you know that pin dimension stays fixed, in pixels, even if you are zooming in or out.
What do you think of this (complex) feature (mkmapview overlay) where I draw a circle of 10 meters around the center of the group and small circles at each point included in the group.

cvp

@RocketBlaster05 in the previous example, the trash pin is in the circle but at more than 10 meters from at least one point.

RocketBlaster05

@cvp that looks amazing. Take as much time as you like because that is beyond what I would have thought of.

Thanks!

cvp

@RocketBlaster05 Github updated with version with map overlay (I spent 3 hours this morning, don't worry, for my fun because I did not know this feature)
Please try it and tell me your opinion.

I don't forget the 2 requests:
1. display number of points in the crosshair area at center of cross
2. automatically add a trashed pin at close crosshair area

Both will be done before end of tomorrow.

Don't forget that you need to zoom a lot before to see a circle with radius of 10m

cvp

@RocketBlaster05 sorry, I think I didn't upload the right code, waits one minutes, sorry

cvp

@RocketBlaster05 GitHub uploaded with

RocketBlaster05

@cvp looks great!

RocketBlaster05

@cvp I have a question. I see that for the number three in the center of the marks it has a white background, (I assume to make it easier to see) is it possible to apply the same thing to the trash emoji? I realized it was rather difficult to see on the hybrid map, and thought a white background would likely help

JonB

@RocketBlaster05 Out of curiosity, is this for some sort of class project? .You have mentioned a few times your deadline, and teachers comments...

cvp

@RocketBlaster05 said:

apply the same thing to the trash emoji

Sure it is, but in this way, you would hide the map behind...
I'll do it.

Nb. Be patient for the more complex request about automatic add of a new trash to existing crosshair area.

cvp

@RocketBlaster05 the trash could even hide the face pin. Sure you want that?

RocketBlaster05

@cvp hm... nevermind then. If anything I’ll work towards finding a more suitable image in the future. Til then what is there now is fine.

@JonB yes it’s a school project and maybe a future app design if I stick with it

Edit: I will continue to develop the app @cvp in regards to the question below

cvp

@RocketBlaster05 said:

stick with it

Sorry, I don't understand this English expression

RocketBlaster05

@JonB @cvp if you want to know, I have a goal to make an app that encourages community cleaning efforts primarily through the map I’ve been developing with the abundance of help from @cvp. I had a rather bare one version for a school presentation and since then have wanted to fully develop the app. I genuinely believe that at least pushing the app out there could make a difference, even if only it would be a small one

cvp

@RocketBlaster05 I'm sincerely happy and ready to help...Don't hesitate to ask me for supplemental functionalities or nicer aspects.

Ɖdit: I don't forget the last improvement asked

cvp

This feature to automatically add a new trash pin to an existing group is not so easy as I thought.
With the added circle overlay feature, it becomes very complex because if the group receives a new point, its center will change and I have to remove the overlay and create a new one.
I hope for tomorrow...

JonB

@RocketBlaster05 but is this for a coding class, where you are presenting this work as your own? If so, it seems that you are not learning to code or debug by having cvp so all of the work, even if he is willing.

Or is this for some sort of civics class? In which case "I had a great idea, and found someone on the internet to code it up" seems totally legit.

RocketBlaster05

@JonB I have already done the part where I have to present my work. I have not asked Cvp for any of this help before then. I simply need help because I’m trying to collect data and the methods to do so are beyond my comprehension. The class does not revolve around coding, but rather this is my choice for my engineering project. I am not presenting any of the work Cvp has done as my own. I only wish to get some data as it is the only thing I am missing for my project.

RocketBlaster05

Beyond what I said above, I do genuinely want to bring my idea beyond the classroom. I want to push out an app that helps encourage people to recycle, and it just so happens that the main part is by far the toughest. Beyond the map, it is unlikely I will need much assistance other than a couple pointers here and there.

cvp

@RocketBlaster05 Understood. I'm already far in my new feature but I meet problems...
And, enough for today.
Next tomorrow
Have a good afternoon.

RocketBlaster05

@cvp thank you. See you tomorrow. Sorry for all the confusion

cvp

@RocketBlaster05 Github updated with the new feature of automatically add a new trash pin in an existing deleted group. After a lot of tests, it seems to work.
But, unfortunately, the iOS mapkit has a known bug (lot of references in internet) of not always refreshing the map, that will say that removed pin's and removed overlays (here, the circles) are still visible and could hide the new ones.
But, locations.txt file is correct, and if you close and restart the script (not Pythonista it-self) , you will see your new crosshairs values and their new circles. Hoping it is ok for you.

cvp

@RocketBlaster05 this schƩma only to show you that the circle I draw around the center of the group of points is not exactly correct.
The area where you could add a trash pin which would be automatically included in the group is the darkest green area I have manually contoured.

If you prefer this solution where I draw a circle of 10m of radius around each point of a group, tell me.

RocketBlaster05

@cvp I think just the one circle would be best. However I was testing it and the circle seems to have a fairly small range when it comes to transforming the pins. I had a pin well within the circle and it did not update it. Is it based off of other pins or the center of the circle? I also noticed that the center of the circle moved after I got one to transform so that is why I’m asking.

Thanks!

cvp

@RocketBlaster05 said:

Is it based off of other pins or the center of the circle?

A trashed pin will be added to a group only if the distance between this pin and all points of the group is less than 10 meters, thus it is not sufficient that the pin would be inside the circle.
Don't forget that a group contains points where each point has to be distant of all other ones with less than 10m.
That's why I propose you the other solution than a centered circle...with this marvelous schĆ©ma šŸ˜€

RocketBlaster05

@cvp ah ok I understand now. After you explained it yes I think your schema would be good.

cvp

@RocketBlaster05 Please confirm That I modify the script to only show circle around each deleted point in a group, as circles superpose, the darker green becomes the group area.

Ideally, if I could draw only this, it would be the solution, but I think it is very very complex.

RocketBlaster05

@cvp that does sound very complex. I’m not going to ask you to do it but if you want to challenge yourself then go ahead. For me what you proposed earlier seems just fine.

cvp

@RocketBlaster05 said:

. For me what you proposed earlier seems just fine.

Try it in updated Github but delete locations.txt first

cvp

@RocketBlaster05 As I replaced small circles of points by big circles of 10m, it is no more very visible where points really are. Thus I changed GitHub version to show big and little circles

cvp

@RocketBlaster05 thƩ 2 trash are not included because outside the red contour

RocketBlaster05

@cvp Looks good. I could see how this eventually could be confusing but the chances of more than 3 markers being placed within 10m of each other really is unlikely so I think it will not be much of an issue.

cvp

@RocketBlaster05 Not sure I'll try to solve this problem of inner part, but I'm still open to other easier features and for other bugs of course.

RocketBlaster05

@cvp I know you worked very hard to make these circles appear, but now I need a function to remove them off of the map. The goal here was that after trash was marked, another user would come by (hopefully clean it) then clear the trash marker, as there is no longer trash present. However I want to prevent people from just saying they cleaned it. I would like to make it so that, specifically for the crosshairs, it would take three presses to clear the marker. Once the user presses it once, they can no longer press it, as some variable (set for that specific crosshair) would be set to True, not allowing them to press it again. If they tried to, a message could appear in console saying something along the lines of "You already marked this location as clean."

This may be a lot to take in so by all means ask any questions, I'd be glad to clarify things.

Thanks as always!

cvp

@RocketBlaster05 For your information, if interested by technical aspects, it should be possible to draw a filled area with the union of circles drawn around all points of the group using the ObjectiveC object named MKOverlayPathRenderer, created with CGPath to which a UIbezierPath could be converted, and an UIbezierPath is the objectinstance of ui.Path.
And this is a only summary šŸ˜….
Briefly said, it is very complex for me, but not impossible. Perhaps in a second life.

cvp

@RocketBlaster05 said:

clear the marker

One more time, obviously due to my English level, I' m notsure that I understand correctly.
Could you list an ordered sequence of touch actions (number taps, type of press) and their result.
Thanks and sorry

cvp

@RocketBlaster05 after reading deeper, would it not be easier if the tap on the crosshair does show a button "clear trash" that you could only pressed once?
Tapping this button should also clear the circles and this status should also be stored in the file.
Correct?

RocketBlaster05

@cvp Here is what I mean: (Clear is the same thing as remove)

  1. Circles are set and user can click on them (as you already have programmed)
  2. When the popup happens for the crosshair or a normal trash pin, there should be a button titled "Trash is Cleared"
  3. Specifically for the crosshair, however, it should have in the button a set of parentheses of how many presses are still needed to remove the pin. For an example, originally, the pin will say "Trash is Cleared (3)" but after someone presses it, it will then say "Trash is Cleared (2)"
  4. For the normal trash pins, it will only take one press to remove them. For the crosshairs, it should take 3 as mentioned above. Simply deleting them from the map and locations.txt file is all that needs to happen.

Hopefully this is understandable. If you need more clarifications just ask. Thanks!

cvp

@RocketBlaster05 Wen are the circles them-selves removed?
And you say, removed from the file, sure?

cvp

@cvp Can you still add a trash in the group, even when the group has been partially cleaned?

RocketBlaster05

@cvp yes. The idea is that once it reaches zero, any pins in the circle (including those added before it reaches zero) will be removed

cvp

@RocketBlaster05 ok, for tomorrow when you wake up, and you would see if I did correctly understand šŸ™„

RocketBlaster05

@cvp šŸ‘ sounds good

cvp

@RocketBlaster05 iOS MapKit does not allow a text in the button at right in the detail bubble list.
Only an emoji is allowed. I propose 🚮 and under: "(n)" if group.

For a trash pin, do you want "(1)" below or nothing

cvp

@RocketBlaster05 do you like this?

And

RocketBlaster05

@cvp yes that looks good.

cvp

@RocketBlaster05 there is not yet any process in my script, only display...still thinking

RocketBlaster05

@cvp is it possible to put the word ā€œneededā€ next to the (3) display? That would be the easiest for the user to understand. If not then just the (3) will be good.

cvp

@RocketBlaster05 so asked, so received

RocketBlaster05

@cvp sorry if this an annoyance but I would prefer if the (3) was above needed. Sorry

cvp

@RocketBlaster05 so thus

RocketBlaster05

@cvp yes. Sorry for the inconvenience

cvp

@RocketBlaster05 said:

Sorry for the inconvenience

No problem, it took me 5 minutes

cvp

@RocketBlaster05 new Github available with some refreshing bugs solved and new feature of cleaning trash included. Please test and tell me

When a group is cleaned, it's pins disappear but it's circles will stay until next run.

RocketBlaster05

@cvp works great! Once you manage to get the last step done of clearing the circles, I believe the map will finally be done! If I do follow through with making this an app, would you want payment or something? At the very least credits? I feel guilty having you do so much...

cvp

@RocketBlaster05 said:

clearing the circles

I'm almost sure that I'll not be able to do that because, as said in a previous post, it seems that map overlay has a bug of refreshing... But I think you can live with it because next run clean them.

cvp

@RocketBlaster05 said:

would you want payment or something

Yes, of course, you will pay me a beer when we meet šŸ˜‚

cvp

@RocketBlaster05 Forget it. I should thank you to let me have fun (and learn also).

RocketBlaster05

@cvp if you say so. At the very least I’ll put a special thanks to cvp somewhere in the app. One last thing I can think of... You should only be able to remove a pin or press the remove button if you are within 20 meters of it. Also, you should only be able to press the button one time per user (store on file that the user has already pressed the button to clear on the crosshairs) I don’t know how doable the second part is but I believe this is my final task for you. Thanks as always, cvp!

cvp

@RocketBlaster05 I could only display button, or enable it, if less than 20m.
But the other request: what is a "user"? If you want I keep user(s) in the file, what is their "Id"?

cvp

@RocketBlaster05 what do you prefer:
- no button if user at more than 20m
- button disabled
- button enabled but alert if pressed and no action

RocketBlaster05

@cvp 3rd option is best. I want people to know they can clean it, but when they press on it it will tell them they have to be closer.

RocketBlaster05

@cvp Maybe this whole ā€˜ID’ thing would be for later... I do expect to have an account system because it will open up for customizable accounts (and some money making) so that’s going to be a while down the line I guess.

cvp

@RocketBlaster05 Github ok with check 2*parameter of 10meters

RocketBlaster05

@cvp works great as always. Looks like this should be the final thing I ask of you for now. Until tomorrow or something when I inevitably run into an issue. I just have to decide where to go from here... Most likely I will work on making minigames as it was the next part of my plan. I have a roadmap I am trying to follow so hopefully I can stay on track.

cvp

@RocketBlaster05 Good luck and always read to help, or debug (less funny)