Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Map overlay works on 1.1 and not 1.5

Map overlay works on 1.1 and not 1.5

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Map overlay works on 1.1 and not 1.5

Postby pslloo » Tue Jun 09, 2009 11:07 am

Can anyone help? My map overlay program below works with the emulator on version 1.1 and not version 1.5. This program overlays a square on the map. The map is displayed correctly but without the overlay on 1.5. I have spent a lot of time on this problem but just cannot see the problem.

Thanks
pslloo :cry:

package com.dynastysoftware.MapsTest;

import android.app.Activity;
import android.content.Context;
import android.location.Address;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.TextView;
import android.location.Criteria;am
import android.location.Geocoder;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Paint;
import android.graphics.Paint.*;
import android.graphics.RectF;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;
import com.google.android.maps.MapView.LayoutParams;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class MapsTest extends MapActivity {
private MapView mapView;
private MapController mapController;
Double latGeo, lngGeo;
GeoPoint geoPoint;
ArrayList<GeoPoint> mapPoints = new ArrayList<GeoPoint>();

LocationManager locationManager;
Geocoder geoc;

TextView latText;
TextView lngText;
TextView locationText;


// Paint paint = new Paint();
// MapOverlay mapOverlay = new MapOverlay();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

latText = (TextView) findViewById(R.id.latText);
lngText = (TextView) findViewById(R.id.lngText);
locationText = (TextView) findViewById(R.id.locationText);

String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(context);
/*
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);

provider = locationManager.getBestProvider(criteria, true);
*/
// Replace line below with LINES above if criteria is required
String provider = locationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);

geoc = new Geocoder(getApplicationContext(), Locale.getDefault());

mapView = (MapView)findViewById(R.id.mapView);

mapController = mapView.getController();


// mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.displayZoomControls(true);

showCountryMap();


// Listen for location changes
final LocationListener locationListener = new LocationListener () {
public void onLocationChanged (Location location) {

displayLocationOnMap(location);
//getLocationFromAddress();
}

public void onProviderDisabled (String provider) {
}

public void onProviderEnabled (String provider) {
}

public void onStatusChanged (String provider, int status, Bundle extras) {
}
};

locationManager.requestLocationUpdates(provider, 200, 1, locationListener);

}

@Override
protected boolean isRouteDisplayed() {
// This method must return true if your Activity
// is displaying driving direction otherwise return false
return false;
}




private void displayLocationOnMap(Location location) {
Double lat, lng;

String locationString = "No found";

// Reverse geocoder
if (location != null) {

lat = location.getLatitude();
lng = location.getLongitude();

latGeo = lat * 1E6;
lngGeo = lng * 1E6;

geoPoint = new GeoPoint(latGeo.intValue(), lngGeo.intValue());
mapPoints.add(geoPoint);


mapController.animateTo(geoPoint);
mapController.setCenter(geoPoint);
mapController.setZoom(14);

// Overlay
// MapOverlay mapOverlay = new MapOverlay();
MapOverlay1 mapOverlay = new MapOverlay1();
List<Overlay> listOfOverlays = mapView.getOverlays();
// listOfOverlays.clear();
listOfOverlays.add(mapOverlay);


try {
List<Address> addresses = geoc.getFromLocation(lat, lng, 10);
StringBuilder sb = new StringBuilder();

if (addresses.size() > 0) {
int len=0;
int totlen=0;
for (int i=0; i<=addresses.get(0).getMaxAddressLineIndex(); i++) {
len = addresses.get(0).getAddressLine(i).length();
// this section is supposed to wrap if > 40 characters - not finished
if (i > 0) {
totlen = totlen + len;
if (totlen > 40) {
sb.append("n").append(addresses.get(0).getAddressLine(i));
}
else {
sb.append(",").append(addresses.get(0).getAddressLine(i));
}
}
else {
totlen = len;
sb.append(addresses.get(0).getAddressLine(i));
}
}
}
locationString = sb.toString();
} catch (IOException e){};
}
else {
lat = 0.0;
lng = 0.0;
}

NumberFormat formatter = new DecimalFormat("0.00000000");

String latStr = formatter.format(lat);
String lngStr = formatter.format(lng);

latText.setText(latStr);
lngText.setText(lngStr);
locationText.setText(locationString);
}





// Display the map of the country according to the Locale when program first started
private void showCountryMap() {
Double lng=0.0, lat=0.0;
String locationString;

locationString = "";

// Show country on Google map
String countryLocale = Locale.getDefault().getDisplayCountry();

try {
List<Address> mylocation = geoc.getFromLocationName(countryLocale, 1);
StringBuilder sb = new StringBuilder();
if (mylocation.size() > 0) {
lat = mylocation.get(0).getLatitude();
lng = mylocation.get(0).getLongitude();

latGeo = lat * 1000000;
lngGeo = lng * 1000000;

for (int i=0; i<=mylocation.get(0).getMaxAddressLineIndex(); i++) {
sb.append(mylocation.get(0).getAddressLine(i)).append("n");
}
locationString = sb.toString();
}
} catch (IOException e){}

NumberFormat formatter = new DecimalFormat("0.00000000");

String latStr = formatter.format(lat);
String lngStr = formatter.format(lng);

latText.setText(latStr);
lngText.setText(lngStr);
locationText.setText(locationString);

GeoPoint pointCountry = new GeoPoint(latGeo.intValue(), lngGeo.intValue());

mapController.animateTo(pointCountry);
mapController.setCenter(pointCountry);
mapController.setZoom(3);
}



private class MapOverlay1 extends Overlay
{
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {


Projection projection = mapView.getProjection();

// Create and setup paint brush
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
paint.setStrokeWidth(2f);

if (shadow == false) {
for (GeoPoint mapPoint : mapPoints) {
Point plotPoint = new Point();
projection.toPixels(mapPoint, plotPoint);

// Nearly transparent
paint.setStyle(Style.FILL);
paint.setARGB(60,255,0,0);
canvas.drawRect(plotPoint.x-6, plotPoint.y+6, plotPoint.x+6, plotPoint.y-6, paint);
paint.setARGB(255,255,0,0);
// No fill
paint.setStyle(Style.STROKE);
canvas.drawRect(plotPoint.x-7, plotPoint.y+7, plotPoint.x+6, plotPoint.y-6, paint);
}
}
}

}

}
pslloo
pslloo
Freshman
Freshman
 
Posts: 4
Joined: Tue Jun 09, 2009 10:56 am

Top

getFromLocation() broken in Android 1.5

Postby latenite4 » Thu Aug 13, 2009 12:07 am

running Ubuntu 9.04 Android 1.5

Testing Geocoder functions with Android handset emulator.
getFromLocation() always returns a list (of addresses) of size()==0.

Anybody know the current status of this problem? Is it fixed in donut?

Thx,
Rod

Geocoder gc = new Geocoder(getApplicationContext(),
Locale.getDefault());
try{
List<Address> addresses = gc.getFromLocation(lat, lng, 1);
StringBuilder sb = new StringBuilder();
if(addresses.size() >0){ // always == 0 ??
Address address = addresses.get(0);

for (int i = 0;i< address.getMaxAddressLineIndex(); i++)
sb.append(address.getAddressLine(i)).append("\n");

sb.append(address.getLocality()).append("\n");
sb.append(address.getPostalCode()).append("\n");
sb.append(address.getCountryName());
addressString = sb.toString();
}

Log.d("debug","numAddr " + addresses.size()+" adrstr before asgn= " +
addressString +" sb= "+sb.toString());


}
latenite4
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jun 05, 2009 4:55 pm
Location: McKinney, TX

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests