Question: `Gmap.addoverlay()` causes map to zoom out if you've called `getEarthInstance()`.

Using ge plugin 6.2.1.6014, Chrome/Mac OSX and {Firefox,Chrome}/Windows Vista Home Premium (Cross-posted on [Google Earth API issues](https://web.archive.org/web/20160103051231/https://code.google.com/p/earth-api-samples/issues/detail?id=769)). See the test code [here](https://www.heywhatsthat.com/hacks/ge62bug.html).

Shortly after the second marker appears, the maps zooms out, even though noone asked it to.
By putting an `alert()` in that callback and extending the `timeout()` interval, I'm pretty sure it's the `addOverlay()`, not the `getEarthInstance()`, where the problem occurs.

To immunize my code, I tried the commented code in the callback, but it's apparently too late by then.

So, is there any way to determine the version of the plug-in without calling `getEarthInstance()`? Perhaps some hacking with `google.load`? Without a clean way to detect the version of the plug-in, I'd have to disable the `G_SATELLITE_3D_MAP` as long as any of this version of the plug-in remain installed out there, which, I'm thinking, is pretty much forever?

I'm calling `getEarthInstance()` because I want to enable a few layers and set a click listener on the globe. Is it possible to do either of those things without `getEarthInstance()`?

Answer: 
I fear you have to keep your DB clean by yourself … The easiest way would be using `NSFetchRequest`: When importing your updated data you can run a query against the existing data and decide what you want to do.

As Marcus S. Zarra mentioned in [another thread](https://stackoverflow.com/questions/3185885/prevent-duplicates-when-importing-rss-feed-to-core-data) about this topic:

> 
> When you are importing a new row you can run a query against the
>  existing rows to see if it is already in place. To do this you create
>  a NSFetchRequest against your entity, set the predicate to look for
>  the guid property and set the max rows returned to 1.
> 
> 
> I would recommend keeping this NSFetchRequest around during your
>  import so that you can reuse it while going through the import. If the
>  NSFetchRequest returns a row you can update that row. If it does not
>  return a row then you can insert a new row.
> 
> 
> When done correctly you will find the performance more than
>  acceptable.
> 
> 
> 

Another source for good information are Apples Programming Guides: [Core Data Programming Guide](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreData/index.html#//apple_ref/doc/uid/TP40001075-CH2-SW1)
As Stated in Apple Docs <https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdImporting.html>

You need to loop the data model and handle it from there like this 

Example:

```
// loop over employeeIDs
// anID = ... each employeeID in turn
// within body of loop

NSString *predicateString = [NSString stringWithFormat: @"employeeID == %@", anID];

NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateString];

```

Personally I do not like this method and I wrote this snippet of code that handles this in a pro-efficient manor and which is straight forward! I noticed with Apples method I ran into issues with strings having different characters such as capitol letters and spaces. Below code is tested and working if you rename all your corresponding objects correctly I honestly believe this is the most efficient way to accomplish not adding duplicates in core data.

```
-(void)AvoidDuplicatesinDataModel
{
    // Define our table/entity to use
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Users"
                                              inManagedObjectContext:managedObjectContext];

    // Setup the fetch request
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:entity];

    // Define how we will sort the records
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"users"
                                                                   ascending:NO];
    NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

    [request setSortDescriptors:sortDescriptors];
    [sortDescriptor release];

    // Fetch the records and handle an error
    NSError *Fetcherror;
    NSMutableArray *mutableFetchResults = [[managedObjectContext
                                            executeFetchRequest:request error:&Fetcherror] mutableCopy];

    if (!mutableFetchResults) {
        // Handle the error.
        // This is a serious error
    }

    //here usersNameTextField.text can be any (id) string that you are searching for
    if ([[mutableFetchResults valueForKey:@"users"]
         containsObject:usernameTextField.text]) {
        //Alert user or handle your duplicate methods from here
        return;
    }
}

```