Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed GoogleMaps/lib/CLDC11.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,30 @@
*/
package com.codename1.googlemaps;

import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.GoogleMap;
import com.codename1.impl.android.AndroidNativeUtil;
import java.util.HashMap;

import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.LatLng;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.ViewGroup;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import com.codename1.impl.android.AndroidImplementation;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.LifecycleListener;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.codename1.io.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import android.os.Looper;
import android.view.View;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.Polyline;
import android.graphics.Point;
//import com.codename1.impl.android.AndroidImplementation.PeerDraw;
import com.codename1.io.Log;
import com.codename1.ui.Display;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import java.util.HashMap;

public class InternalNativeMapsImpl implements LifecycleListener {
private int mapId;
Expand All @@ -59,21 +55,25 @@ public class InternalNativeMapsImpl implements LifecycleListener {
private Point lastPoint;
private boolean showMyLocation;
private boolean rotateGestureEnabled;
private static boolean initialized = false;

static {

if(AndroidNativeUtil.getActivity() != null) {
android.util.Log.d("CN1 Maps", "Initializing maps");
android.util.Log.i("CN1 Maps", "Initializing maps");
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
android.util.Log.i("CN1 Mapss", "static()->getMainLooper:ok");
initMaps();
} else {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
android.util.Log.d("CN1 Mapss", "static()->runOnUiThread:ok");
initMaps();
}
});
}
} else {
android.util.Log.d("CN1 Mapss", "Did not initialize maps because activity was null");
android.util.Log.i("CN1 Mapss", "static()->Did not initialize maps because activity was null");
}
AndroidNativeUtil.registerViewRenderer(MapView.class, new AndroidNativeUtil.BitmapViewRenderer() {
private boolean rendering;
Expand Down Expand Up @@ -116,7 +116,9 @@ public void run() {
while(finished[0] == null) {
try {
finished.wait(100);
} catch(InterruptedException er) {}
} catch(InterruptedException er) {
android.util.Log.d("CN1 Mapss", "invokeAndBlock()->ex:"+er.toString());
}
}
}
}
Expand All @@ -127,9 +129,11 @@ public void run() {
}
}
});

}
private static boolean initialized = false;

private static void initMaps() {

if (!initialized) {
initialized = true;
try {
Expand All @@ -140,12 +144,15 @@ private static void initMaps() {
v.onCreate(AndroidNativeUtil.getActivationBundle());
v.onResume();
v.getMap();
android.util.Log.i("CN1 Mapss", "initMaps()->initialized:"+initialized);
} catch (Exception e) {
supported = false;
System.out.println("Failed to initialize, google play services not installed: " + e);
e.printStackTrace();
}
}
} else
android.util.Log.i("CN1 Mapss", "initMaps()->initialized:"+initialized);

}

public long addMarker(final byte[] icon, final double lat, final double lon, final String text, final String snippet, final boolean callback) {
Expand All @@ -155,7 +162,7 @@ public long addMarker(final byte[] icon, final double lat, final double lon, fin
public void run() {
MarkerOptions mo = new MarkerOptions();
if(text != null) {
mo.title(text);
mo.title(text);
}
if(icon != null) {
Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length);
Expand All @@ -165,8 +172,12 @@ public void run() {
mo.snippet(snippet);
}
mo.position(new LatLng(lat, lon));

Marker m = mapInstance.addMarker(mo);

if (text!=null)
m.showInfoWindow();

if(callback) {
listeners.put(m, key);
}
Expand Down Expand Up @@ -344,6 +355,7 @@ public void onMapLongClick(LatLng point) {
});
mapInstance.setMyLocationEnabled(showMyLocation);
mapInstance.getUiSettings().setRotateGesturesEnabled(rotateGestureEnabled);
android.util.Log.i("CN1 Mapss", "installListeners()->loaded:ok");
}
});

Expand All @@ -367,6 +379,8 @@ public void run() {
}
}
});
android.util.Log.i("CN1 Mapss", "createNativeMap()->mapInstance:"+(mapInstance!=null?"ok":"null"));
android.util.Log.i("CN1 Mapss", "createNativeMap()->view :"+(view!=null?"ok":"null"));
return view;
}

Expand Down Expand Up @@ -452,43 +466,50 @@ public boolean isSupported() {
}

public void onCreate(Bundle savedInstanceState) {
android.util.Log.d("CN1 Mapss", "onCreate()");
try {
if (view != null) {
view.onCreate(savedInstanceState);
initMaps();
mapInstance = view.getMap();


}
} catch (Exception e) {
e.printStackTrace();
}
}

public void onResume() {
android.util.Log.i("CN1 Mapss", "onResume()");
try {
if(view != null) {
mapInstance = view.getMap();

view.onResume();
mapInstance = view.getMap();
installListeners();
}
android.util.Log.i("CN1 Mapss", "onResume()->ok");
}else
android.util.Log.i("CN1 Mapss", "onResume()->view:null");

} catch (Exception e) {
e.printStackTrace();
android.util.Log.e("CN1 Mapss", "onResume()->err:"+e.toString());
}
}

public void onPause() {
android.util.Log.i("CN1 Mapss", "onPause()");
try {
if(view != null) {
view.onPause();
}
} catch (Exception ex) {
ex.printStackTrace();
android.util.Log.e("CN1 Mapss", "onPause()->err:"+ex.toString());
}
}

public void onDestroy() {
android.util.Log.i("CN1 Mapss", "onDestroy()");
try {
if(view != null) {
if (view.getParent() != null) {
Expand All @@ -499,6 +520,7 @@ public void onDestroy() {
}
} catch (Exception e) {
e.printStackTrace();
android.util.Log.e("CN1 Mapss", "onPause()->err:"+e.toString());
}
}

Expand All @@ -513,6 +535,7 @@ public void onSaveInstanceState(Bundle b) {
}

public void onLowMemory() {
android.util.Log.i("CN1 Mapss", "onLowMemory()");
try {
if(view != null) {
view.onLowMemory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ -(long long)addMarker:(NSData*)param param1:(double)param1 param2:(double)param2
} else {
marker.userData = nil;
}

//mapView.appearAnimation = kGMSMarkerAnimationPop
mapView.selectedMarker = marker;
[marker retain];
[pool release];
});
Expand Down
Loading