Git Product home page Git Product logo

google-maps-ios-utils's People

Contributors

adapptorsimon avatar amuramoto avatar arriolac avatar chainedtothewoods avatar dion-loetscher avatar domesticmouse avatar farshadmb avatar googlemaps-bot avatar h4j4x avatar haimingxu679 avatar hansemannn avatar ihacksubhodip avatar it-sam avatar jpoehnelt avatar jschmid avatar jum avatar kostrzynski avatar lhasiuk avatar mandisaw avatar mangerlahn avatar markmcd avatar mountainvat avatar ryanecrist avatar semantic-release-bot avatar shafeerp avatar sonxurxo avatar sviklim avatar vincentisambart avatar wangela avatar willum070 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-maps-ios-utils's Issues

The 'MyApp' target has transitive dependencies that include static binaries

My Podfile looks like:

target 'Telemetry' do
use_frameworks!
//...
pod 'GoogleMaps', '~> 1.13.2'
pod 'Google-Maps-iOS-Utils'
end
end

I get the error The 'MyApp' target has transitive dependencies that include static binaries: (/Users/imac/MyApp/Pods/GoogleMaps/Frameworks/GoogleMaps.framework). Can u help me?

Issue While same coordinates

I am using this class for showing pis as cluster but while i have same coordinate it shows pin number instead of pin.
I am not able to see to pin when at same coordinate.
So that I am not able to tap on the pin.
mapissue

no icon generator

there is no icon generator for ios, but it exists for android which is a huge help.Please include an icon generator for ios

Google Maps SDK for iOS Utility Library crashing issue

i've implemented marker clustering(Google Maps SDK for iOS Utility Library ) along with google maps.crash i'm getting is on deallocating cluster manager object.i'm deallocating google map and cluster manager objects and delegate in viewDidDisappear and deinit as i'm initialising it in viewDidLoad.it works fine upto 10.0,but for higher when i'm doing same in deinit it's working fine but crashes in lower version.below is my code

deinit{
        print("DEINIT")
      
        if(googleMapView != nil){
            googleMapView!.removeObserver(self, forKeyPath: "myLocation")
        }
        if(clusterManager != nil)
        {
            clusterManager.clearItems()
            clusterManager.setDelegate(nil, mapDelegate: nil)
            clusterManager = nil
        }
    }`

Troubles when I'm building project with a Podfile

After last changes in your master branch I got error in my project which used this library by pods. The problem is maps-ios-utils classes can't figure out where are google-maps headers.
My Podfile fragment:
target 'ClusterCheck' do
pod 'Google-Maps-iOS-SDK', '1.9.2'
pod 'Google-Maps-iOS-Utils-QuadTree', :git => 'https://github.com/DDRBoxman/google-maps-ios-utils.git'
end

It used work perfectly until last changes happened in repository. I'm not strong in Pods, and I have no idea is the reason.

Working to add a function to remove every cluster and annotations from the map

Hi Mickael,
I noticed that there is no feature to remove every cluster and annotations from the map if we want to add some new one. I am trying to make that feature works.

I was thinking that the best way to do it was to keep all the Spot added in a NSMutableArray.
And do a [ArraySpot removeAllObjects] [self.mapView clear] in my mainController. But I think that's not working. The annotations are just added to the old ones. If you got few advice to tell me which direction I should take, it could be really helpful.

Marker Customization Swift

Hello, I'm trying to implement Marker Customization described here ->https://github.com/googlemaps/google-maps-ios-utils/blob/master/CustomMarkers.md where explains how to implement in objective C. My project uses swift and my knowlegde in objective C is very low. I've tried to convert the example to swift, but the project doesn't build, trhows an error (see attatchment). With this message i've sent 2 files, an image with the error, and a file with a partial example of my code. is there an issue with my code or something else? Thanks in advance.

P.D.
When i implement Clustering without custom markers everything works fine.
i'm using swift 2.3, cocoapods with static libraries (using bridge header file)
Google-Maps-iOS-Utils (1.1.2), GoogleMaps (2.1.0), and xcode Version 8.0 (8A218a).
error-swift-marker-custom
example_swift_test.txt
POIItemClass.txt

Algo/GMUClusterAlgorithm.h not found

Hi there,

I just updated the pod to use the new marker icons, but I get a file not found error for Algo/GMUClusterAlgorithm.h in the GMUClusterManager.h file.

My code is like it is in the example file.

Do you know what could be wrong?

Minimum bucket size for clustering

I would only like to cluster if the number of elements is > than a certain limit otherwise the current one (think is 4) is overkill for some use cases. Is this possible?

GMUDefaultClusterRendererTest fails

Was trying to understand why my code works not as expected and found issue with unit tests.
It seems to be issue with OCMock

Return value cannot be used for method; method signature declares '{?={?=dd}{?=dd}{?=dd}{?=dd}}' but value is '{?={CLLocationCoordinate2D=dd}{CLLocationCoordinate2D=dd}{CLLocationCoordinate2D=dd}{CLLocationCoordinate2D=dd}}

The Google map delegate broken

It seems like that when I implement the cluster function on my map, the idleAtCemeraPosition is not being called. It sounds like somewhere is holding the map from idle.

"Use of undeclared type GMSAutocompleteResultsViewController"

My ios Swift app was using GoogleMaps v1.13.2, today I updated my pods (to 2.0.1), now I am getting the following errors:

Use of undeclared type GMSAutocompleteResultsViewController
Use of undeclared type GMSPlace

I open the GoogleMaps pod and I don't see GMSPlace.h or GMSAutocompleteResultsViewController.h files. Were they removed? Why?

marker custom icon and info window

Before I attempt adding marker clusterer to my project, I would like to ask this:

Right now in my project I create a marker for every object of my data model
let marker = GMSMarker(position: position)
....
marker.map = mapView

And I override the following method for presenting my own info window
func mapView(mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
let infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindow", owner: self, options: nil)[0] as! CustomInfoWindow
//customization code for the infoWindow
.......
return infoWindow
}

When my data model changes I call
mapView.clear()
and I add the new markers

If I use marker clusterer
Will I be able to add GMSMarker objects to the clusterer. Can they have custom icons (per marker) and custom info windows?
Will I be able to clear all markers from the clusterer and add new ones (when I get new data from my backend)?

Thanks in advance for any help / advice

Info Window for annotation/marker

Hi,

I was thinking about a feature of info window which will be visible when tap on any annotation/marker. This feature already exist in Android version of Google map utils. Please suggest if it is yet to implement or we can use this feature in existing code.

Thanks

Strange issue

I get this error :

    NSAssert(itemToClusterDistanceMap.count == _items.count,
             @"All items should be mapped to a distance");

in line 168 at GMUNonHierarchicalDistanceBasedAlgorithm.m file

Debug helpers :
_items contain 2 elements
itemToClusterDistanceMap contain 1 key

debug of for loop at line 133 :

  1. In the first execution he will add the second item (in _items array) to processedItems array.
  2. In the second execution he will check if ([processedItems containsObject:item]) continue; which return true because second item was add at first execution.
  3. As result he has _items and itemToClusterDistanceMap with different count which cause the issue

High CPU usage

Hi there. I have implemented the clustering on my app but the CPU usage has gone pretty bad. I get sometimes 130% for just scrolling. I have something like 100 markers but even when I zoom in to just a few I still get high CPU usage which does not happening if I remove the clustering at all. I am clustering everytime the user moves the map a bit (maybe there is a better way of doing it?)

Google-Maps-iOS-Utils not working,when added manually

Hi,
I've added two folders "Clustering and QuadTree" from Google-Maps-Utils library to integrate marker clustering but its not showing clusters.
Below is my code-
class ViewController: UIViewController,GMSMapViewDelegate,GMUClusterManagerDelegate{

@IBOutlet var gmsMapView: GMSMapView!
let kClusterItemCount = 10000
let kCameraLatitude = -33.8
let kCameraLongitude = 151.2
private var clusterManager: GMUClusterManager!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    let camera = GMSCameraPosition.cameraWithLatitude(kCameraLatitude,
                                                      longitude: kCameraLongitude, zoom: 10)
    gmsMapView = GMSMapView.mapWithFrame(CGRect.zero, camera: camera)



    // Set up the cluster manager with default icon generator and renderer.
    let iconGenerator = GMUDefaultClusterIconGenerator()
    let algorithm = GMUNonHierarchicalDistanceBasedAlgorithm()
    let renderer = GMUDefaultClusterRenderer(mapView: gmsMapView, clusterIconGenerator: iconGenerator)
    clusterManager = GMUClusterManager(map: gmsMapView, algorithm: algorithm, renderer: renderer)


    generateClusterItems()

    // Call cluster() after items have been added to perform the clustering and rendering on map.
    clusterManager.cluster()

    // Register self to listen to both GMUClusterManagerDelegate and GMSMapViewDelegate events.
    clusterManager.setDelegate(self, mapDelegate: self)

}



// MARK: - GMUClusterManagerDelegate

func clusterManager(clusterManager: GMUClusterManager, didTapCluster cluster: GMUCluster) {
    let newCamera = GMSCameraPosition.cameraWithTarget(cluster.position,
                                                       zoom: gmsMapView.camera.zoom + 1)
    let update = GMSCameraUpdate.setCamera(newCamera)
    gmsMapView.moveCamera(update)
}

// MARK: - GMUMapViewDelegate

func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {
    if let poiItem = marker.userData as? Spot {
        NSLog("Did tap marker for cluster item \(poiItem.marker.title)")
    } else {
        NSLog("Did tap a normal marker")
    }
    return false
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


// MARK: - Private

/// Randomly generates cluster items within some extent of the camera and adds them to the
/// cluster manager.
private func generateClusterItems() {

    dispatch_async(dispatch_get_main_queue()) {

    if(self.gmsMapView != nil){


    let extent = 0.2
    for index in 1...self.kClusterItemCount {
    let marker:GMSMarker = GMSMarker()
    marker.title = "marker"
    let lat = self.kCameraLatitude + extent * self.randomScale()
    let lng = self.kCameraLongitude + extent * self.randomScale()

    marker.position = CLLocationCoordinate2DMake(lat, lng)
    marker.snippet = "1234"
    marker.icon = self.generateSpot(index)
   let spotObje:Spot = Spot()
   spotObje.location = marker.position
   spotObje.marker = marker
   spotObje.marker.map = self.gmsMapView
   self.clusterManager.addItem(spotObje)
    }
    }

    }

}

func generateSpot(count:Int) -> UIImage{


    let sizeVar:CGSize = CGSize(width: 41, height: 37)

    let customeMarker :CustomMarker = NSBundle.mainBundle().loadNibNamed("customview", owner: self.view, options: nil).first! as! CustomMarker

    customeMarker.frame = CGRectMake(customeMarker.frame.minX,customeMarker.frame.minY,customeMarker.frame.width,customeMarker.frame.height)
    customeMarker.mappedNumbers.layer.masksToBounds = true
    customeMarker.mappedNumbers.layer.cornerRadius = 8
    customeMarker.mappedNumbers.text = String(count)


    UIGraphicsBeginImageContextWithOptions(sizeVar, false, 0)
    customeMarker.layer.renderInContext(UIGraphicsGetCurrentContext()!)

    /// customeMarker.drawViewHierarchyInRect(customeMarker.bounds, afterScreenUpdates: true)

    let newImage = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()


    return newImage

}

/// Returns a random value between -1.0 and 1.0.
private func randomScale() -> Double {
    return Double(arc4random()) / Double(UINT32_MAX) * 2.0 - 1.0
}

}

//Spot.h

import <Foundation/Foundation.h>

@import CoreLocation;

import "GMUClusterItem.h"

@interface Spot : NSObject

@Property (nonatomic) CLLocationCoordinate2D location;

@Property (nonatomic, strong) GMSMarker *marker;

@EnD

Counting for the Cluster not right

Hi DDRBoxman, I noticed that the counting in GstaticCluster.m is not right, I was thinking maybe it's just in my app but the demo got the same too. If you are zooming down with differents steps for the zoom you can see that the global counting does not stay the same. I am trying to find out the problem but I did not find anything for the moment.

Markes without snippet and label.

When i try show infowindow, i be using the method:

  • (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
    _mapView.selectedMarker = marker;
    return YES;
    }

    But this not show nothing.

    In debug i can add the title label and snippet, like imagem below:
    captura de tela 2015-09-02 as 02 23 44

But when method mapView:didTapMarker is called, this receive a marker only position, without the title and snippet, like image below:

captura de tela 2015-09-02 as 02 25 39

How can show Infowindow?

Native Swift

I was wondering if a native Swift code base is in the works as I would like to use Swift code only in my app and Swift is the way to go in the long run. Just wondering if that is on the road map currently. Thanks!

Google-Maps-iOS-Utils not installing with cocoa pods.

I am trying to use Google-Maps-iOS-Utils in my project through Podfile where I use use_fameworks!.
It's giving error because GoogleMaps is static. Then I tried to copy Google-Maps-iOS-Utils manually and install only GoogleMaps from Podfiles. I am getting below error after that,

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_GMUClusterManager", referenced from:
type metadata accessor for __ObjC.GMUClusterManager in ViewController.o
"OBJC_CLASS$_GMUDefaultClusterIconGenerator", referenced from:
type metadata accessor for __ObjC.GMUDefaultClusterIconGenerator in ViewController.o
"OBJC_CLASS$_GMUDefaultClusterRenderer", referenced from:
type metadata accessor for __ObjC.GMUDefaultClusterRenderer in ViewController.o
"OBJC_CLASS$_GMUNonHierarchicalDistanceBasedAlgorithm", referenced from:
type metadata accessor for __ObjC.GMUNonHierarchicalDistanceBasedAlgorithm in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is a very serious problem and I am stuck here. Dropping use_frameworks! is not an option for me. I do not know if I have I added Google-Maps-iOS-Utils correctly. I need a serious help here.
Thanks.

Collection was mutated while being enumerated

I am developing an app that show users in nearby area in the maps. I use cluster manager to cluster users. The users/cluster items are updated periodically from server. Steps are :

  • call [clusterManager clearItems]
  • add all new item to the cluster manager
  • call [clusterManager cluster]

But sometimes I got error : Collection was mutated while being enumerated in GMUNonHierarchicalDistanceBasedAlgorithm.m, particularly in this place :

/**
 * Returns the set of clusters of the added items.
 */
- (NSArray<id<GMUCluster>> *)clustersAtZoom:(float)zoom {
  NSMutableArray<id<GMUCluster>> *clusters = [[NSMutableArray alloc] init];
  NSMutableDictionary<GMUWrappingDictionaryKey *, id<GMUCluster>> *itemToClusterMap =
      [[NSMutableDictionary alloc] init];
  NSMutableDictionary<GMUWrappingDictionaryKey *, NSNumber *>     *itemToClusterDistanceMap =
      [[NSMutableDictionary alloc] init];
  NSMutableSet<id<GMUClusterItem>> *processedItems = [[NSMutableSet alloc] init];

  for (id<GMUClusterItem> item in _items) {  <--- HERE
  ....    

Any advice how to prevent this error from occurring?

Use of undeclared type 'GMUClusterManagerDelegate'

I followed the steps in Swift.md to manually add Google-Maps-iOS-Utils files to my project. And it succeeded in building. But when I try to get a view controller implement GMUClusterManagerDelegate, an error shows

Use of undeclared type 'GMUClusterManagerDelegate'

Here are my screen shots -

  • Bridging Header

screen shot 2016-10-27 at 22 14 40

- GMUMarkerClustering.h

screen shot 2016-10-27 at 22 15 36

- Group

screen shot 2016-10-27 at 22 16 28

- Use Header Maps

screen shot 2016-10-27 at 22 22 29

Can anyone help me with this? Thanks a lot!

Where is Geojson utils on IOS?

I had use google map android utils geojson, it is great! However, where is geojson utils on ios? I can't find it, the current ios utils only has cluster.

using custom markers

please i need a full example to use custom markers "GMSMarker" with clustering , i'm not familar with objective c , i already tried to use #21 but it doesn't work for me , please help!!

Unable to find a specification for `Google-Maps-iOS-Utils (~> 1.0)`

Uncomment this line to define a global platform for your project

platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'

target 'SwiftDemoApp' do

Comment this line if you're not using Swift and don't want to use dynamic frameworks

#use_frameworks!

Pods for SwiftDemoApp

pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils', '~> 1.0'
end
This is pod file code but still i get same error "Unable to find a specification for Google-Maps-iOS-Utils (~> 1.0)"
I reinstall cocoapod then also i get this type of error

Multiple markers at same point can't be seen

If I add 3 markers at same point for ex (41.3833, 2.18333), the cluster shows as 3. But when I try to zoom out, I can never separate the marker from cluster. There is no way I can see individual markers at that point.
screen shot 2014-11-27 at 5 31 47 pm
screen shot 2014-11-27 at 5 31 20 pm

Cocoapods issue with use_frameworks

We need to specify "use_frameworks!" in our podfile since we have swift pods. However we get the following error with cocoapods 1.0.1 when including the Google Maps Utils pod:

use_frameworks!

pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'

ERROR:
target has transitive dependencies that include static binaries: (/Users/jeff/Documents/Clients/IGS/Projects/Choice360Connect/Pods/GoogleMaps/Subspecs/Base/Frameworks/GoogleMapsBase.framework, /Users/jeff/Documents/Clients/IGS/Projects/Choice360Connect/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMapsCore.framework, and /Users/jeff/Documents/Clients/IGS/Projects/Choice360Connect/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMaps.framework)

GMUClusterRendererDelegate willRenderMarker called twice for each marker

I have created the GMUClusterRendererDelegate in my code and implemented the willrenderMarker function. I notice that this function loops through the visible markers 2x for each marker. For instance, if I have 5 visible markers, the function gets called for each marker in succession, and then AGAIN for each marker in succession. Is this expected behavior?

Unable to find a specification for `Google-Maps-iOS-Utils`

Trying to perform pod install in the Obj-C sample project throws this error.

Temporarily solved it by changing the podfile to

source 'https://github.com/CocoaPods/Specs.git'

target 'ObjCDemoApp' do
  pod 'GoogleMaps'
  #pod 'Google-Maps-iOS-Utils'
  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/googlemaps/google-maps-ios-utils'
end

Heat map request.

Why there is no heat map utility for iOS like Android? Or is it there and I could not find it!

No clustering for less than 4 markers

I experienced that I need to have at least 4 markers for the clustering to be performed. When I have 3 markers, there is no clustering, no matter in which zoom level I am.

screenshot 2016-07-20 13 14 07

Is there something I am missing? Thanks

No info window shown

I'm trying to get the info window to show when a marker is tapped.
In didTapMarker I set the title manually with marker.title = "THE TITLE"
Nothing is shown.

It works if I add the markers directly like this:
let marker = GMSMarker(position: initialPosition) marker.map = self.mapView
but not when I add it via the cluster.

Any suggestions?

Cannot install pod

When I do pod install I get
[!] The 'Pods-test' target has transitive dependencies that include static binaries: (/Users/user/Documents/test/Pods/GoogleMaps/Subspecs/Base/Frameworks/GoogleMapsBase.framework, /Users/user/Documents/test/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMapsCore.framework, and /Users/user/Documents/test/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMaps.framework)

I need to use use_frameworks! in my Podfile, since I have swift pods as well.

Any suggestions?

Google-Maps-iOS-Utils not working

Hi,
I've added two folders "Clustering and QuadTree" manually from Google-Maps-Utils library to integrate marker clustering but its not showing clusters.
And also added required bridging-header.
I want to add marker and cluster based on users current location, markers are working, but unable to get cluster working.
Below is my code-
`import UIKit
import Alamofire
import SwiftyJSON
import CoreLocation
import GoogleMaps

/// Point of Interest Item which implements the GMUClusterItem protocol. COdE FROM GOOGLE SAMPLE PROJECT
class POIItem: NSObject, GMUClusterItem {
var position: CLLocationCoordinate2D
var name: String!

init(position: CLLocationCoordinate2D, name: String) {
    self.position = position
    self.name = name
}

}

let kClusterItemCount = 10000
let kCameraLatitude = -33.8
let kCameraLongitude = 151.2

class SearchTab: UIViewController ,GMSMapViewDelegate ,CLLocationManagerDelegate ,GMUClusterManagerDelegate{

var tapId = Int()

var getParams :Dictionary<String, String> = [String: String]()   // DECLARING DICTIONARY FOR POST PARAMETERS

var params :[[String: AnyObject]] = [[:]]   // DECLARING DICTIONARY FOR Result PARAMETERS

var searchCount = Int()

var locationManager = CLLocationManager()

var lati = Double()
var long = Double()
var boundArray = [CLLocationCoordinate2D]()

var mapview = GMSMapView()

var clusterManager: GMUClusterManager!


@IBOutlet weak var mapView: UIView!



override func viewDidLoad() {
    super.viewDidLoad()

                //DELEGATES MAP AND LOCATION MANAGER
                mapview.delegate = self
                self.locationManager.delegate = self
                self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
                self.locationManager.requestWhenInUseAuthorization()
                self.locationManager.requestLocation()

                // Set up the cluster manager with default icon generator and renderer.
                let iconGenerator = GMUDefaultClusterIconGenerator()
                let algorithm = GMUNonHierarchicalDistanceBasedAlgorithm()
                let renderer = GMUDefaultClusterRenderer(mapView: mapview, clusterIconGenerator: iconGenerator)
                clusterManager = GMUClusterManager(map: mapview, algorithm: algorithm, renderer: renderer)

                // Register self to listen to both GMUClusterManagerDelegate and GMSMapViewDelegate events.
                clusterManager.setDelegate(self, mapDelegate: self)
}

// MARK: - GMUClusterManagerDelegate

func clusterManager(clusterManager: GMUClusterManager, didTapCluster cluster: GMUCluster) {
    let newCamera = GMSCameraPosition.cameraWithTarget(cluster.position,
                                                       zoom: mapview.camera.zoom + 1)
    let update = GMSCameraUpdate.setCamera(newCamera)
    mapview.moveCamera(update)

}



    /// Returns a random value between -1.0 and 1.0.
    private func randomScale() -> Double {
        return Double(arc4random()) / Double(UINT32_MAX) * 2.0 - 1.0
    }

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{

            let location = locations.first

            self.locationManager.stopUpdatingLocation()
            getParams["lat"] = location?.coordinate.latitude
            getParams[lon"] = location?.coordinate.longitude

            setupMap()
 }

func locationManager(manager: CLLocationManager, didFailWithError error: NSError)
{

    print("Errors: " + error.localizedDescription)
}

//Mark-- setup location on map using the users current location  
func setupMap(){


                let lat :Double =  Double(getParams["lat"]!)    
                let long = Double(getParams["lon"]!)            
                let camera = GMSCameraPosition.cameraWithLatitude(lat , longitude: long, zoom: 10.0)

                let userLocation = CLLocationCoordinate2D(latitude: lat, longitude: long)

                let userCam = GMSCameraUpdate.setTarget(userLocation)

                mapview = GMSMapView(frame: self.mapView.bounds)
                mapview.myLocationEnabled = true
                mapview.settings.myLocationButton = true



                mapview.delegate = self

                mapview.camera = camera

                self.lati = lat
                self.long =  long
                 self.getParams = [:]
                self.getParams["lat"] = "\(lat)"
                self.getParams["lng"] = "\(long)"
                self.mapView.addSubview(mapview)

               //CALLING FUNCTION TI SEARCH Required results near the users current location 
                gpsSearch()
 }



//MARK -- LOCAtion BASED SEARCH
func gpsSearch() {


    LoadingOverlay.shared.showOverlay((self.navigationController?.view)!)
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {     
            dispatch_async(dispatch_get_main_queue()) {

            self.getParams["miles"] = "5"

                            Alamofire.request(.POST, "MY SEARCH URL", parameters: self.getParams, encoding:.JSON).responseJSON
                {


                    response in switch response.result
                    {


                    case .Success(let res):
                        //                            print(res)

                        let userData = JSON(res)
                        if userData["error"] != "false"{
                            print(userData["error"])
                            self.displayALert("Aw snap! No results found. Give us another shot")
                            LoadingOverlay.shared.hideOverlayView()
                            return
                        }



                        self.params = res["result"]  as! [[String:AnyObject]]
                        print("THESE ARE Marker RESULTS COUNT-- \(self.params.count)")


                        var count = 0
                        for  result in self.params{
                            //      print("--------- \(result)")
                            let marker = GMSMarker()
                            marker.icon = UIImage(named: "annotImage")
                            marker.infoWindowAnchor = CGPointMake(0,0)
                            marker.accessibilityLabel = "\(count)"

                            marker.position = CLLocationCoordinate2DMake(result["lat"]!.doubleValue , result["lng"]!.doubleValue)

                            marker.map = self.mapview
                            count += 1

                            let cor =  marker.position
                            self.boundArray.append(cor)
                        }


                        let location = CLLocationCoordinate2D(latitude: self.lati , longitude: self.long)

                        self.boundArray.append(location)//["coordinate"] = location

                        let lastLoc = CLLocationCoordinate2D(latitude: self.params[count - 1]["lat"]!.doubleValue , longitude: self.params[count - 1]["lng"]!.doubleValue)

                        let bounds = GMSCoordinateBounds(coordinate: location, coordinate: lastLoc)
                        let camera = self.mapview.cameraForBounds(bounds, insets: UIEdgeInsets())!
                        self.mapview.camera = camera

                        let zoomCamera = GMSCameraUpdate.zoomOut()
                        self.mapview.animateWithCameraUpdate(zoomCamera)


                         var clustItem = 0
                        let extent = 0.2
                        for result in self.params{

// print("--------- (result)")
let lat = result["lat"]!.doubleValue + extent * self.randomScale()
let lng = result["lng"]!.doubleValue + extent * self.randomScale()
let name = "Item (clustItem)"
let item = POIItem(position: CLLocationCoordinate2DMake(lat, lng), name: name)

                            clustItem += 1
                            self.clusterManager.addItem(item)
                        }


                        self.clusterManager.cluster()


                        LoadingOverlay.shared.hideOverlayView()


                    case .Failure(let error):
                        LoadingOverlay.shared.hideOverlayView()
                        self.displayALert("Something went wrong, please try again")

                        print("Request failed with error: \(error)")
                    }
            }

        }}


}
//MARK: GMSMapViewDelegate
func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
    // Get a reference for the custom overlay
    let index:Int! = Int(marker.accessibilityLabel!)
    let customInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as! CustomInfoWindow
    customInfoWindow.title.text = self.params[index]["name"] as! String
    customInfoWindow.subTitle.text = self.params[index]["address"] as! String
    customInfoWindow.backgroundColor = UIColor.blackColor()
    customInfoWindow.alpha = 0.7
    customInfoWindow.layer.cornerRadius =  5
    customInfoWindow.title.textColor = UIColor.whiteColor()
    customInfoWindow.subTitle.textColor = UIColor.whiteColor()
    //
    let vancouver = CLLocationCoordinate2D(latitude: self.params[index]["lat"]!.doubleValue, longitude: self.params[index]["lng"]!.doubleValue)
    let vancouverCam = GMSCameraUpdate.setTarget(vancouver)
    mapview.animateWithCameraUpdate(vancouverCam)

    return customInfoWindow
}


//MARK :- FUNCTION TO DETECT tap on Infowindow of map


func mapView(mapView: GMSMapView, didTapInfoWindowOfMarker marker: GMSMarker) {

    //        print("Tapp detected")
    let index:Int! = Int(marker.accessibilityLabel!)

    tapId = self.params[index]["winery_id"] as! Int
     print("Tapp detected---- win id \(tapId)")


}





func displayALert(userMessage:String){              //FUNCTION FOR DISPLAYING ALERT ON EMPTY FIELDS

    let alertController:UIAlertController = UIAlertController(title: "Alert", message:
        userMessage, preferredStyle: UIAlertControllerStyle.Alert)

    alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default,handler: nil))


    self.presentViewController(alertController, animated: true, completion: nil)

}   //END OF DISPLAY ALERT FUN

}
`
The app builds and runs ,but clusters are not not getting displayed, please help

When Zoo in not show more markers

When the app start, show total of 253 marks in one circle, apparently fine. After zoo in, not show separated markers.

My _mapView is instantiated from a UIView.

In Xcode, not show issues or warnings. In console not show error.

iOS 8
Google Maps Version: Google Maps SDK for iOS version: 1.9.13516.0

I will do more tests, but if someone can help, I will be very grateful!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.