Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Map API, need suggestions for how to execute ideas
-
@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.
-
@RocketBlaster05 That will not be for today...sorry
Don't you want to center the map on the center of all previous pin's? -
@RocketBlaster05 did you try several runs with multiple pin's, like
-
#!python2 ??
-
@ccc old line of omz
-
@ccc works without the line
-
@ccc you know my standard response to your advices: you're always right 😇
-
@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?
-
@cvp yes! that would be very helpful. I am very thankful you are willing to help out!
-
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)
-
@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
-
@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)
-
pin_colors = { "Dropped Pin": 0, # red "Current Location": 2, # purple } … pin_color = pin_colors.get(title, 1) # default to green
-
@ccc said:
pin_color = pin_colors.get(title, 1) # default to green
pinView.pin_color = pin_colors.get(tit, 1) # default to green
-
@RocketBlaster05 and tell me if you want to see your own photo instead of a purple pin
-
@RocketBlaster05 or, if you prefer,
Or, with with some drops of blood 😂
-
@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
-
@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.
-
An image of like a trash bag… 🚮🗑♻️☠️🤢💰💩🤮
-
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'.- do you want the two buttons 3D and MapType and their process?
- do you want a photo/emoji instead of the purple pin of your own location?
- map will be visible automatically if you remove the line "v.hidden = True" in the main.
- 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