Capturing an image from leaflet map and saving it to S3 - ruby-on-rails

I have a rails website where people can create custom maps using Leaflet JS. When they share those maps, I want the preview image to be an image of that map.
Right now, when a users map updates, I cache the GeoJSON that defines their map look. When I cache that GeoJSON, I would also like to grab an image of their map and save it to S3 so I can use it when they share their map.
The problem is, all the plugins I've found are designed for the user to capture their own image. Since leaflet runs in the browser, is there an easy way to capture this image, or do I need to setup a server hosted version of Leaflet?

Related

Map Kit Location Images

I am using Map kit to display a bunch of locations and data related to it.
When I use Apple Maps I can see that locations have related images provided by Yelp.
Does map kit provide a way to access those images? Is there any way to obtain images from a respective location??
Thanks.
Those images are not part of the SDK and you can't use them within your app directly, but you can use Yelp API to get business information, including images. Check https://www.yelp.com/developers/documentation/v3/business for more information.

How to show GeoJson javascript data as layer in Google Maps in iOS swift

I have requirement that is, I have to show GeoJson data (java script file) as a layer in Google maps either using Native or Web view. I have checked few forums, as per they said, it is possible only for Android to load java script for loading data layer in Google maps.
So, my requirement is, I want to show some java script which contains geojson data as layer and then after that, I have to draw a route or path from start point to end point in map(like user started walking from 1 place to other place around 1 to 10 kms like footsteps).
I seen in Google maps forum, only Android and Web possible this kind requirement.
And I have checked MapBox library too, I am not sure whether it will help to my requirement. But, my preference is Google Maps.
Anyone can suggest me how to achieve this?

Generating Images from maps

How do you capture an image of a user generated map, like one created using Leaflet.js?
Here is my example:
I have a website that generates a map.
I want to save an image of that map
e.g. when the user shares their profile, the preview image is of their map.
I know facebook, Strava, and most other services show images of a user map in their news feeds instead of showing interactive maps.
The problem
The map is generated client side, so grabbing an image of the map serverside isn't possible
Possible Solution
Once a map is generated, use PhantomJS to capture a screenshot of the map, and crop out the rest of the website.
Question
Since this is such a common thing to do, is anyone aware of a better or more standard way of grabbing these screenshots? I've seen things like the mapbox static API, but that doesn't capture the custom pins and line features on my maps.
I'm using rails for the back end.
You can make your map to be able to read the url params and set its state from it. When the user changes something on the map, the map's state is saved as url parameters and then send it/store it on the server for PhantomJS to generate it.
E.g.
&coords=123.123,10.123,54.54,45.11&zoom_level=5&....

Custom icons for kml layer using in Google maps Api

I want to display data from kml file, which is situated here http://maps.google.com/maps/ms?f=q&msa=0&output=kml&msid=201434694813577429889.0004ba2d12b7538131e5e .
It is output from MyPlaces. I want to do more stuff with it - change icons, use clustering and so on, so embedding is not good solution.
I've tried to load the file using KmlLayer in GoogleMapsApi, which works, but I don't know, how to change icons and how to get data for each marker (coordinates, description, ..).
Actually, what I need is just the access to the data in kml, I am able to do all other programming on my own. The file is continuously changing so I need to do all the stuff online.
You could use a 3rd party KML parser (through a proxy) like geoxml3 or geoxml-v3. They render the KML using native Google Maps Javascript API v3 objects, you can modify those using the Google Maps Javascript API. When you do that you lose the benefit of KmlLayer's tile based rendering, so with complex KML, you may have performance issues.
example with your KML (seems to have a character encoding issue)

Accessing Map Tiles of MKMapView

I'm currently developing an app that needs to display a map of where the user is currently located in the world. For technical reasons, I need to access every map tiles as an image (png/jpg) before going in the rendering pipeline.
I have tried 3rd party services like MapBox, MapQuest as they have a REST api that enables me to receive a png/jpg of a tile according to the requested location. The issue here is that MapBox isn't free, so I was wondering if there was a way to access the tiles that Apple provides in it's maps app. What service are they using under the hood? Would I be violating some terms of use by going with this approach.
Please note that using some integrated "do-it-all" UIMapView is not an option for me, I need the image directly.
Thanks
Google has a REST API. You can see the details here https://developers.google.com/maps/documentation/staticmaps/?csw=1. It does cost money if you go over the usage limits.
I manually download Map Tiles for my app, but I don't use MKMapKit. I have my own MapView and I am using a combination of MapBox, Thunderforest, CalTopo, OSM, and map tiles that I generated and host on AWS. All of them have a pretty easy map tile URL scheme, but you do have to pay for most of them.

Resources