Я следую этому сообщению , потому что у меня простая проблема.Только мне нужно использовать его в Typescript Code.
В Android этот код:
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition position) {
LatLngBounds bounds = googleMap.getProjection().getVisibleRegion().latLngBounds;
LatLng northeast = bounds.northeast;
LatLng southwest = bounds.southwest;
Context context = getApplicationContext();
CharSequence text = "ne:"+northeast+" sw:"+southwest;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
});
Мне нужно написать в Typescript / Nativescript код и написать так:
public onCameraChange() {
var bounds = this.gMap.getProjection().getVisibleRegion().latLngBounds;
console.log('bounds', bounds)
var northeast = bounds.northeast;
console.log('northeast', northeast)
var southwest = bounds.southwest;
console.log('southwest', southwest)
var context = application.android.context.getApplicationContext();
var text = "ne:"+northeast+" sw:"+southwest;
console.log('context,text', context,text)
}
В ней покажите эту ошибку:
JS: ERROR TypeError: Cannot read property 'getProjection' of undefined
JS: ERROR CONTEXT {
JS: "view": {
JS: "def": {
JS: "nodeFlags": 16793601,
JS: "rootNodeFlags": 1,
JS: "nodeMatchedQueries": 0,
JS: "flags": 0,
JS: "nodes": [
JS: {
JS: "nodeIndex": 0,
JS: "parent": null,
JS: "renderParent": null,
JS: "bindingIndex": 0,
JS: "outputIndex": 0,
JS: "checkIndex": 0,
JS: "flags": 1,
JS: "childFlags": 16793601,
JS: "directChildFlags": 16777217,
JS: "childMatchedQueries": 0,
JS: "matchedQueries": {},
JS: "matchedQueryIds": 0,
JS: "references": {},
JS: "ngContentIndex": null,
JS: "childCount": 9,
JS: "bindings": [],
JS: "bindingFlags": 0,
JS: "outputs": [],
JS: "element": {
JS: "ns": "",
JS: "name": "GridLayout",
JS: "attrs": [
JS: [
JS: "",
JS: "class",
JS: "page"
JS: ]
JS: ],
JS: "template": null,
JS: "componentProvider": null,
JS: "componentView": null...
Пожалуйста, вы можете поделиться со мной любой идеей, как решить?Я хочу, чтобы API требовал широту, длину и радиус, я могу получить широту и длину от центральной точки, но не смог найти способ получить радиус.
ОБНОВЛЕНИЕ:
public onCameraChange(arg) {
this.gMap = event.object.gMap;
var bounds = this.gMap.getProjection().getVisibleRegion().latLngBounds;
console.log('bounds', bounds)
var northeast = bounds.northeast;
console.log('northeast', northeast)
var southwest = bounds.southwest;
console.log('southwest', southwest)
var context = application.android.context.getApplicationContext();
var text = "ne:"+northeast+" sw:"+southwest;
console.log('context,text', context,text)
}
ПОКАЗАТЬ:
JS: bounds LatLngBounds{southwest=lat/lng: (-66.41815185001424,-63.11405181884765), northeast=lat/lng: (66.41891785546429,63.11484139412641)}
JS: northeast lat/lng: (66.41891785546429,63.11484139412641)
JS: southwest lat/lng: (-66.41815185001424,-63.11405181884765)
Приложение закрыто автоматически
- Как рассчитать радиус в этой части?
- Почему мое приложение закрыто?