nativescript-google-maps-utils icon indicating copy to clipboard operation
nativescript-google-maps-utils copied to clipboard

app crashed when setupMarkerCluster

Open weijyewang opened this issue 6 years ago • 11 comments

I'm trying to enable clustered marker in android using angular 6.

My code was rather simple, and I had no idea when the app crashed (it exited to the emulator home screen automatically) when it ran this line of code GoogleMapsUtils.setupMarkerCluster(this.mapView, markerSet);

Here's the code snippet: import section:

import { MapView, Marker, Position } from 'nativescript-google-maps-sdk';
import * as GoogleMapsUtils from "nativescript-google-maps-utils"

inside the function

let markerSet = [];
this.journeys.forEach(journey => {
	let theMarker: Marker = new Marker();
	theMarker.position = Position.positionFromLatLng(journey.latitude, journey.longitude);
	theMarker.title = journey.vehicleRegistrationNumber;
        theMarker.snippet = journey.vehicleRegistrationNumber;
	markerSet.push(theMarker);
});

setTimeout(() => {
	GoogleMapsUtils.setupMarkerCluster(this.mapView, markerSet);
	this.zoomCenterOnMultipleMarkers();
}, 1000)

Does anyone get it to working on angular? Please help

weijyewang avatar Aug 27 '18 09:08 weijyewang

Does anyone get it to working on angular?

sedrak1987 avatar Sep 29 '18 07:09 sedrak1987

remove this mapView._markers.push(marker); statement form this method setupMarkerCluster() in index.android.ts.

There is no _markers property in the MapView class

Secondly, There should be minimum 5 markers to showing cluster

fawadmukhtar avatar Oct 09 '18 06:10 fawadmukhtar

dear where is index.android.ts file?(maybe in node_modules, if yes, then why I must change core files)

sedrak1987 avatar Oct 17 '18 07:10 sedrak1987

@sedrak1987 because the app is crashing at that point. you need to fork it and update that file to get a expected result

fawadmukhtar avatar Oct 17 '18 07:10 fawadmukhtar

yes, but after plugin update or node_modules remove in every time I need remove that line. Right?

sedrak1987 avatar Oct 17 '18 08:10 sedrak1987

No, when you fork it and use your own. that's control from your package.json file

fawadmukhtar avatar Oct 17 '18 08:10 fawadmukhtar

can you give me instruction steps how do it, please?

sedrak1987 avatar Oct 17 '18 08:10 sedrak1987

@sedrak1987

  1. Fork this project in Github image
  2. Do whatever changes neccessary like what @fawadmukhtar suggested in your forked new repo.
  3. Publish to npm or Nativescript plugin market (https://docs.nativescript.org/plugins/building-plugins#step-4-publish-your-plugin)
  4. Install back your published version.

weijyewang avatar Oct 17 '18 08:10 weijyewang

Thanks a lot. Will try later when will get free time

sedrak1987 avatar Oct 17 '18 08:10 sedrak1987

Remember to uninstall this original nativescript plugin before using your forked version. Else you will have namespace conflict

weijyewang avatar Oct 17 '18 09:10 weijyewang

Can anyone help me? I can not publish my fork

Zampa98 avatar Feb 05 '19 10:02 Zampa98