question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot access to the 'setCameraTarget' method.

See original GitHub issue

I’m submitting a … (check one with “x”)

  • question
  • any problem or bug report
  • feature request

If you choose ‘problem or bug report’, please select OS: (check one with “x”)

  • Android
  • iOS

cordova information: (run $> cordova plugin list)

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.2.9 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.2.0 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

"@ionic-native/core": "^4.7.0",
"@ionic-native/google-maps": "^4.7.0",

Current behavior: setCameraTarget throws an error. I’m trying to set the camera with multiple ILatLng objects, to bound the map to their locations.

Expected behavior: Should work.

Screen capture or video record: 4-21-2018 1-37-43 pm

Related code, data or error log (please format your code or data):

import { HttpClient } from '@angular/common/http';
import { Component } from '@angular/core';
import { GoogleMap, GoogleMaps, GoogleMapsEvent } from "@ionic-native/google-maps";
import { IonicPage } from 'ionic-angular';
import { Store } from '../../models/store.model';
import { LocationsConstants } from './locations.constants';
import { Observable } from 'rxjs/Observable';

@IonicPage()
@Component({
  selector: 'page-locations',
  templateUrl: 'locations.html',
})
export class LocationsPage {

  public map: GoogleMap;
  public stores: Observable<Store[]>;

  constructor(
    private _http: HttpClient
  ) { }

  public ionViewDidLoad() {
    this.stores = this._http.get<Store[]>('./assets/data/stores.json');
    this.map = GoogleMaps.create('map', LocationsConstants.MapOptions);
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => this.loadMap());
  }

  public loadMap() {
    this.stores.subscribe(stores => this.placeMarkers(stores));
  }

  public placeMarkers(stores: Store[]) {
    console.log((stores.map(d => d.latlng)));
    this.map.setCameraTarget(stores.map(d => d.latlng));
    for (let store of stores)
      this.map.addMarker({ position: store.latlng, ...LocationsConstants.MarkerOptions });
  }

}

[
	{
		"name": "",
		"location": "",
		"latlng": {
			"lat": 40.334564,
			"lng": -74.487639
		}
	},
	{
		"name": "",
		"location": "",
		"latlng": {
			"lat": 40.8518239,
			"lng": -74.44092739999996
		}
	}
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wf9a5m75commented, Apr 21, 2018
this.placeMarkers(stores).bind(this);
0reactions
manuelstivencommented, Jan 8, 2020

this error continues… anybody can help me?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Any way to set camera target in the script?
Hi all, I was wondering if it was possible for you to define a target for something in the script as opposed to...
Read more >
setCameraTarget - ped - Scripting
I managed to get the camera looking at the ped, I just can't check if it follows cause I can't seem to get...
Read more >
Google Earth Studio - Camera Target & Multi-View - YouTube
Tap to unmute. If playback doesn't begin shortly, try restarting your device. Your browser can't play this video. Learn more. Switch camera.
Read more >
I cannot access the camera in a UIViewController
My goal is to get it activated in viewDidAppear or viewDidLoad, but I also tried testing it by connecting the code to a...
Read more >
Site cannot access camera, but does not seem to be ...
The same problem does not persist on Chrome and Chromium, so I'll be using Chromium for the time being. Due to the way...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found