How to duplicate an already initialised map in openlayers 3 - mapping

How can i duplicate an already initialised map state?
I would like to save the hassle of re-initialising the same map then copying the layers over.

You can reuse the map object on different tags just by changing the target div when you want to use it on different pages.
map.setTarget('map-holder');
If you want to display both maps at the same time then you can try this example
https://openlayersbook.github.io/ch03-charting-the-map-class/example-05.html.
One map cannot have two targets at the same time as far as I know. Hope that helps.

Related

Swift swipe through photos randomly

Originally I had a different post, just wanted to redo it to clean it up.
This is more or less the layout I wanted to go with. Imagine the first imageview had dog pictures, the second one had cat pictures and the third one had rabbit pictures. three folders contain a group of three separate sets of pictures.
What is the best way to set it up so I can randomly swipe, lets say the first image view where it would only show pictures of dogs.
What I am asking is, is there a certain way to create the file structures or link the pictures to each image view?
I have the basics of the random (something with a 4 in it don't remember the method exactly) and the basics of swipe, just was looking for help with linking the photos and file structure.
Please let me know if this still doesn't make sense.
Thank you
EDIT
after messing with this this is where I am at:
with a very simple array basically
catsArray: [String] = ["catpic1","catpic2"......]
then I have it set up as
let randomIndex = Int(arc4random_uniform(UInt32(catArray.count)))
if (sender.direction == .Right)
{
self.catImageView.image = UIImage(named: catArray[randomIndex])
}
just me hacking things off the internet. now I am running into an issue. after a few swipes I get a null images or its just blank. Why is that?
now that I have some of this set up I am debating if I should just use parse for a server or if there is a better way.
thanks
Either approach will work. It's probably a good exercise to write both versions. You'd learn from it.
Your question is far too vague. Are you worried about memory? If so, you should not load the images into an array. Instead load the image names, and load each image as it is swiped on-screen. You might want to load the current image and the next image so it's already in memory and can be displayed without lag.
Are you talking about using a UIPageViewController? That's a good class for managing a set of pages that you can scroll through. There is a sample app from Apple called PhotoScroller that illustrates that technique, along with tiling the images so you can display large images and handle zooming and panning. (The app is written in Objective-C however.)
EDIT:
Your updates make your question a little clearer.
There are lots of ways to handle this. Here's 1.
Create 3 separate folders, one for cats, one for dogs, and one for rabbits. (in your app's documents directory, or in the bundle, if the images will be shipped with the app.)
Use NSFileManager to create 3 separate arrays of filenames. Take a look at the methods contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error: and contentsOfDirectoryAtPath:error:. You should be able to make either of those work.
Then you'll need to scramble your arrays of filenames to create a randomized order. You can use one of the block-based sort methods where your block uses a random number to determine the sort order of each pair of objects.
Finally you'll need to implement the swipe to switch.
It sounds like you are beginner so this is a lot to work through. You should break the problem into pieces and tackle them one at a time.

Save Map Annotation

I just created a map view where the user can make an annotation by dropping a pin. How is it possible to save the annotation, so the user can see it when the app is closed and re-opened? Does anyone know a good tutorial for saving map annotations? Thanks!
Map annotations are nothing different to regular data. The answer to this will depend on many things. For example:
How do you save other data in your map?
How many pins do you need to keep track of?
If you are only saving one pin and thus one lat and one long value, you could use NSUserDefaults. There are lots of tutorials for that around. Here's just one example: http://iphonedevsdk.com/forum/iphone-sdk-tutorials/106311-tutorial-1-how-to-use-nsuserdefault.html

customizing info window for multiple markers

I have seen the google developers video on custom info window for google maps ios sdk and got it. But how to use it when we have multiple markers. In my application i have to point 10 place and have to use that custom infowindow
I got it, we just have to call the customInfoWindow class how many time we want with new set of parameters.
Not sure exactly if this is what the question was - but you can attach a piece of your own data to the marker using marker.userData. You can make this anything you want - an NSDictionary for example. In -markerInfoWindow:(GMSMarker *marker) you can retrieve the userData and based on that, you can decide what view you want to return. Make sure the userData contains sufficient data to decide what your view should contain and you are good to go.

How to show multiple images in a single page of LeavesViewController?

The classes provided by Leaves developed by Tom Brow supports single images for each page of the book with flip effect. In one of our projects we need to show multiple images in a single page along with the flip effect. Has anybody done that with 'Leaves' or is there any other alternative?
We need this images to be added separately so that we can use UIImage selected actions as this images are also required to replaced.This view will also have UITextBox and UILabel.
I know that from iOS 5 on wards UIPageViewController is available which can serve this purpose but for this project we need to support iOS4 also so UIPageViewController can be ruled out.
Try to render two images in a graphics context and then extract the image from the context and draw it in pdfcontext. Hope this might help you.

iOS: Can the UIImagePickerController Default UI be modified?

I am working with a small camera app for a client and I have now finished all functionality of it. In the standard camera controls i need to modify one thing , the cancel button should say gallery instead.
But unless i am missing something i will need to remove the overlay by setting showsCameraControls to NO and then building my entire overlayView from scratch.
I have found this solution but I am afraid to go this route due to the warning in the beginning of the post.
So is there any valid way of doing simple small modifications to the existing camera overlay control UI or do you have to build it from scratch if you need to change one tiiiiiiny thing?
Unfortunately, having been in this situation I can safely say you need to build the controls from scratch. You really only have two options: create your own camera overlay, or use the default one.
Now, you could use the techniques described in the link you cite, and iterate through the various subviews and modify them 'blind'. The rather large danger with this is every time Apple change the internal structure of the image picker it could potentially break your solution. So I'd definitely stay clear of it.

Resources