From the Google Image API documentation
Static Maps service allows up to five unique custom icons per request. Note that each of these unique icons may be used multiple times within the static map
I have more than 5 custom icons per request, maybe up to 40.
Is there a way to overcome this? Is it possible to use sprites in static maps to overcome this?
Here's how I got around this:
You probably already know how, and depending on your source it's going to be different anyway, but collect up all your map data. Required bits are going to be: center point, zoom, map type, and output image size. I am going to assume sensor (if the application has access to GPS) is false. Also you are going to need all of your marker information which will include the icon you are going to use, and the geo coordinates of them.
I POSTed this all to the CF page that is going to make all the magic happen.
Map your first 5 points as normal. Get the results as a .png
Map your next 5 points but add "style=feature:all|visibility:off" to the query string, get result as a .png. This will give you a png with a transparent background but will have all of your marker icons on it. It will be the same size as your initial map, and the markers will be placed correctly withing that rectangle.
Watermark that image on top of your initial map. NOTE: this step is probably going to vary the most depending on your language of choice and what image manipulation features it offers.
Repeat 4 and 5 until you have all of your markers.
Write out you image with all of the markers now on it.
Serve up a link to that file instead of using the normal google link.
I have a more detailed explanation here with some code example in ColdFusion.
Related
I'm using MapBox's static API in a project. I have managed to load maps with the same width and height in terms of latitude and longitude regardless of the resolution. This is so that users see the same area regardless of their screen resolution, for example. The problem is that on larger resolutions features and —especially, text appear much smaller, relatively. For example, these two maps look very similar, except for the size of text (and some other details, like the thickness of lines):
https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285#2x?access_token=ACCESS_TOKEN
https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,13.15/240x126#2x?access_token=ACCESS_TOKEN
Is there a way to compensate for this and have the text on the larger image print larger, and have thicker lines? (in pixel terms). The result being that, say, two 6 inch screens print text in the same real-world size (centimeters) regardless of their pixel count.
I have looked into layers and filters, but it does not seem like there is a straightforward way of achieving this. It looks like maybe designing new maps would be the way to go, but I'm using the default ones and I would not know where to start.
THank you
I'm a bit confused by the premise of your question here. The API's #2x parameter is meant to toggle resolution and should serve exactly the purpose you describe. The reason for different amounts of label information being included in the images you've shared is because you've used different zoom values (13.15 vs. 14.3) and the labels in Mapbox core styles are zoom-dependent, meaning they change based on the zoom value used to generate the map.
With a fixed image width, and no #2x parameter:
/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285?access_token=ACCESS_TOKEN
yields
With a fixed image width, and a #2x parameter:
yields
/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285#2x?access_token=ACCESS_TOKEN
⚠️ Disclaimer: I currently work for Mapbox ⚠️
I am developing a weather radar viewer using Mapbox. In a certain mode, there are 2 Mapbox maps on the screen at the same time showing different modes of the radar. The maps are locked to each other. When one map moves, rotates, or pans - the other one does as well. I did this by simply passing the properties of one map to the other. In the below screenshot, you will see how they are showing identical locations.
What I want to do is - when the user is hovering the mouse over "map1", I would like an identical (ghost or false) cursor on "map2". Here is what I am looking to do:
(edit: What you are looking at is an actual screenshot. Each map is enclosed in a DIV with 50% width of the screen, if this helps to explain)
I don't know if this is even possible in Mapbox. Hopefully someone can give some guidance as I can't find any other questions related to this and I really have no code to show without knowing where to start.
If you attempt to do this inside Mapbox-GL-JS (for instance, by constantly updating the location of a GeoJSON feature layer), I think the performance will be pretty poor.
But since the two views are exactly locked (and presumably the exact same dimensions), you can just do this at an HTML/CSS level. Detect mouse movement on the first map, and update the location of an absolutely-positioned element hovering over the second map to match.
Another approach would be using a canvas element overlaid over the second map, similarly updated.
I'm using Mapbox GL JS. Is there any way I can style my base layer to look like the Mapbox Light example, but showing only the UK?
I assume I would use Mapbox Studio to build my own base layer, but I can't see any way in Studio to filter by country.
If that's not possible, is there any way I could show labels on the UK only, and show other countries as filled polygons? (As per this unanswered question.)
Unfortunately it is not possible to filter by a certain geography when selecting the data source for a layer. If you're working with Mapbox's tiles, they'll always cover the entire planet.
There is the possibility to restrict the map to a certain (rectangular) bounds, with the map.setMaxBounds method (https://www.mapbox.com/mapbox-gl-js/api/#Map#setMaxBounds). This might work reasonably well since you want to restrict the view to the UK, but might not be suitable depending on the geometry you want to restrict the view to.
As a workaround you could create a dataset and add a polygon that covers the entire planet except for the extent you want to show in your map. Then add this dataset in your style as the top most layer and style it with whatever you'd like the empty space in your map to look like.
The workaround has been also suggested in this SO answer, if you can get maptiles for the UK only (the SO answer gives a link, but for Germany) you can
upload them to Mapbox as a dataset, export it to tilesets, and then
to a map as a layer. Delete all other layers
You have also the possibility to Style a single country in Mapbox
studio ref this tutorial. The other countries are still shown, but you can style your map in a way to highlight UK
There is a option that allows you to show only one country highlighted. But drawback is, you lose all the layers and tile-level details. Here is the link https://www.mapbox.com/videos/how-to/map-a-single-country-in-mapbox-studio/.
But if you want to include the tile details as well as whole world map but in that map only one or two or custom amount of countries highlighted, then, from above link of Natural Earth download the zipped file of ne_10m_admin_0_countries and upload.
Go back to your map style, and instead of making a blank one. Add another layer of ne_10m_admin_0_countries in your current map. Select the country in the filter option (in same way as shown in video). And change its opacity. That's it.
Hope it helps. Have a great day.
Ok, here's my problem. I have a HUGE jpg file, 18000 x 18000 pixels 41MB in size.
If you really need to know, it's a map of a section of the country with services.
My project is really simple. I just need to be able to zoom and display this granddaddy size image. All the way from aspect fit to 100% on the iPhone. I'm not too sure if this can be done or how long it will take. Would appreciate any insights.
I have tried using imageView but I read that it really shouldnt exceed 1024 x 1024. That is way below what I have. If you have an idea how to go about doing this, please share!
You should split the image into tiles, at a range of magnifications. Calculate and build these off-line, and ship them as individual files in the app bundle. Given the zoom in your display, pick the closest zoom size. You then select which tiles are needed to cover the screen, and make a grid of them. As the user zooms, select the appropriate tile size.
The benefit of this is that you don't ever have to load HUGE files into memory, only as much as needed.
This is how Google maps does it.
Can't give you any code, sorry!
You should follow an approach similar to what Google Maps and other map sites do. You need to slice the whole map in sections, so the users don't need to load the whole map if it's not always necessary (plus makes loading time way faster)
There's a couple of solutions that might work for you like OpenLayers or even creating a Custom Google Map with your images as seen here and here
Here is an example from Apple for processing large images called PhotoScroller. The images have already been tiled. If you need an example of tiling an image in Cocoa check out cimgf.com
I am creating an iPhone app for OS4.0, and I am attempting to integrate a custom map with a standard MKMapView. I have been provided a map in .eps format (vector image), and I want to somehow overlay this on an MKMapView in and restrict the scrolling boundaries of the map so users cannot scroll outside the boundaries of the custom map. What's the best way to go about this?
I have read some stuff about hosting map tiles on a server, but this seems overly complex for my application. This would just be a map for an attraction roughly the size of a public zoo, so I would think that it would be conceivable to just convert the .eps to a .png file, and overlay it, but this might not give the best performance.
I understand that I could conceivable use a UIScrollView to do the job, but the problem is that I have dynamically generated MKPinAnnotationViews placed on the map, whose position must be based on latitude and longitude, so I can't think on an elegant or reasonable way to do it with a scrollview. Any ideas?
Thanks!
-Matt
Apple has a great bit of example code that will show you what you need to do. Check out the TileMap sample - it is available as part of the (free) WWDC 2010 samples download.
It shows you how to use the gdal2tiles utility to convert an input map into a tree of overlay tiles.
Another good bit of Apple sample code to check out is HazardMap, which is part of the regular SDK samples.