location and map data - best practices?

Has anyone else done anything like this, and what worked for you?

My current project allows users to save and share training event details.
Included in this is a location field.
under-the-hood I’m differentiating the description (track at blah blah blah) from the map coordinates.
A user can opt to include their current location, and I grab that and put it in the coordinate field, which is not displayed when creating the event, but for viewers a “map” button shows up that they can click on the launch into the iOS map app.

Now I’m trying to find the best way to collect the coordinates in a user friendly way.
I thought maybe if the user copies a location from Maps, I could see the text results; name+http://… and give them an option to use that data.
I could add a checkbox to allow them to indicate that the location entered is “findable” in maps, and then when a viewer clicks the “map” button it would format the string correctly to search in maps for it.
But some apps allow you to show a map view and select a location. I have no idea how to do this (yet).

I have make a similar app to the user to find stores in livecode and I have use the google maps to get locations directions etc…
As example as you say about the training…
Your user stop the training like run.

[code]1 The user open the app and want to share the location
2 You ASK the user for the current location (access granted)
3 The App show the map and the current user location(stored in field with a mask like (You are here)
4 User click a button OR a msgbox with (Share or Cancel) and user decide if share the location or not.

[/code]

step 1 and 2 are great.
How are you showing the map in an iOS app?

If you take a look in the >/Examples/iOS/Declares check the ShowURL
Demonstrates how to use the iOS URL handling to open URLs in Safari, Maps, Mail and Phone.

Show url is not the problem. What I’m looking to do is to allow a map to be shown within the app, a location found and retrieved so I can store it and reference it later from within the app.

Then you go custom with api’s…best practice is with google maps api GoeLocation etc…
Simple fast example…
The iOSHTMLViewer and the code bellow with replace
center: {lat: -34.397, lng: 150.644}

[code]

Geolocation /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 100%; margin: 0; padding: 0; }
// Note: This example requires that you consent to location sharing when // prompted by your browser. If you see the error "The Geolocation service // failed.", it means you probably did not give permission for the browser to // locate you. var map, infoWindow; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 6 }); infoWindow = new google.maps.InfoWindow;
    // Try HTML5 geolocation.
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        var pos = {
          lat: position.coords.latitude,
          lng: position.coords.longitude
        };

        infoWindow.setPosition(pos);
        infoWindow.setContent('Location found.');
        infoWindow.open(map);
        map.setCenter(pos);
      }, function() {
        handleLocationError(true, infoWindow, map.getCenter());
      });
    } else {
      // Browser doesn't support Geolocation
      handleLocationError(false, infoWindow, map.getCenter());
    }
  }

  function handleLocationError(browserHasGeolocation, infoWindow, pos) {
    infoWindow.setPosition(pos);
    infoWindow.setContent(browserHasGeolocation ?
                          'Error: The Geolocation service failed.' :
                          'Error: Your browser doesn\\'t support geolocation.');
    infoWindow.open(map);
  }
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
[/code]

Next you can use of event listeners, like
listens for the click event on a marker to zoom the map when the marker is clicked.
listens for the center_changed event to pan the map back to the marker after 3 seconds.

and much more…

Here the full link

This can be done with declares to add the actual map view but it’s a lot of work. Jean Paul put it together so I never touched it but now that his code is gone I might be able to revisit it. It’s fairly niche though and I prefer to create classes that will be more generally useful for everyone. If there’s 3+ people who would find this useful I can look into it again.

Side note, be careful with Google Maps APIs, they are completely changing the limits and price next week. You could end up paying big $$ to Google if your app has many downloads.

You got it free when you start use the api.

And here is the pricing
Maps loaded from mobile is unlimited use without charge both statics and dynamics

Had a call with Google last week, at the current rate my app Packr uses the Google Maps APIs, I would be paying $2000 each month…
But I am using Places autocomplete, not embedded maps.

[quote=395642:@Jeremie Leroy]Had a call with Google last week, at the current rate my app Packr uses the Google Maps APIs, I would be paying $2000 each month…
But I am using Places autocomplete, not embedded maps.[/quote]
I do not disagree with that like Jason say declares will be more useful.
OpenStreetMap is another solution free of charge…

@Jason King I’m using Jean-Paul’s dtMapView in my app and it works really well but now that it is no longer going to be updated, I’d definitely be interested in a MapKit class that can be extended by the community. :slight_smile:

Jason, I would definitely be interested in MapKit addition to iOSKit (or as a separate set of classes). I wouldn’t call spatial mapping to be niche though admittedly I probably have more extreme need for it than many people. I really hope you tackle this! With Jean-Paul no longer supporting or updating his stuff, there are NO other options out there.

There have been several people interested privately as well. It’s on my todo list, but I don’t have an estimate for when I can make a beta available.