We are about to switch to a new forum software. Until then we have removed the registration on this forum.
osX 10.6.8 processing 2.03 Android sdk 2.2.3
android sdk installed and running fine. I need to display dynamic & interactive maps according to the user gps location, which i get using ketai lib (or other) but i cannot find the way to display maps: ---- unfolding lib does not work with p5 2.0 ---- googlemapper lib does not work with android mode i have tryed to add an import to googlemaps using this code after having installed the googlePlayService on the SDK manager::
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;
import android.app.Activity;
import android.os.Bundle;
import android.content.Context; //network connection
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class MapPane extends Activity {
@ Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
GoogleMap map = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
LatLng bastelica = new LatLng(42.000921, 9.050197000000026);
map.setMyLocationEnabled(true);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(bastelica, 13));
map.addMarker(new MarkerOptions()
.title("bastelica")
.snippet("sanpiero corsu")
.position(bastelica));
}
}
----- but it fails when compiling:: No library found for com.google.android.gms.maps No library found for com.google.android.gms.maps.model
what can i do?
thanks
Answers
Never tried it on Android, but there is an Unfolding beta for Processing 2. http://unfoldingmaps.org/rca
Would be great if you give it a try, and report back.
This implementation will surely fail in a Processing environment. It relies on Android's native
MapFragment
, which cannot coexist peacefully with a Processing sketch (unless the sketch is exported into Eclipse and further modified there). It may be possible to use Google Maps in some way, but I would first rely on a Processing library for maps.dear tinagel,
i have tried with your new version; it runs in java mode but when i open the simplest example ("simpleMap") the emulator crashes when "installing the sketch":: FATAL EXCEPTION: Thread-11 java.lang.NoSuchMethodError: processing.core.PApplet.loadImage at de.fhpotsdam.unfolding.tiles.TileLoader.getTileFromUrl(Unknown Source) at de.fhpotsdam.unfolding.tiles.TileLoader.run(Unknown Source) at java.lang.Thread.run(Thread.java:1019) ------ this is exactly the same error i get with the modestmaps lib ------ is it a problem with the loadImage function or with map.draw() i dont know but the error message seems to designate the first one (assuming the url to be good!)
if you get a way to solve that.... thanks
dear calsign,
----as for the import (import com.google.android.gms.maps.*;...) i finally get the way to solve that; you have to create a code folder, find & get the map.jar which is into the addons folder in the sdk, make a clone and put it in the code folder of the sketch. ----as for the code, i have modified it according to the initial error messages i got( for "setContentView(R.layout.map_activity)), (that is solved also); as for MapFragment, i dont know, i am afraid that you are right!...I 'll tell you the issue as soon as possible!
akenaton,
Again, I have no experience with Android. It seems that SimpleMapApp sketch cannot load map tiles from the web.
Does the following web image loading example work on your environment?
https://github.com/processing/processing-android/blob/master/examples/Basics/Web/LoadingImages/LoadingImages.pde
They mention you must ensure to have "INTERNET" permission enabled. Might that already be the issue?
dear tn,
1--- error in your code: img1+ no "size" with android 2 ---the url "http://processing.org/img/processing_cover.gif" is 404, so.... -----changing the url, it works fine on android (and of course with java mode)
Well, that example is from the official Processing Android repo. But did you have to change permissions? Or did it work without?
And in any case, it seems we need to dig actually into Unfolding for Android. Anyone up for that?
dear tn, of course all permissions for internet are in the manifest file. I know think (having tested your example - img1 added, size() deleted, url changed to a working one-) that the problem is between the tileloader and processing. Futhermore, as i have said, i get exactly the same error message with modestMaps lib. I shall try to get a glance in the source java and tell you if i find some work around.
Ok, seems the Processing-Android branch does not provide the loadImage(filename, extension) method anymore.
Meaning, currently Unfolding won't work. I will try testing it end of next week.
no, i dont think so, i can download images from the web without problem, but not tiles, and i think that is linked with the java code in modestmaps a
nd Unfoldings: if your contructor refers to size, (dimensions etc) it cannot work (i am afraid!)
stupid example:
hello, for android it work
//leaving the mapModest lib or unfolding lib questions (which nead a lot of work for amdroid mode....)
1) Is the emulator android mode possible for google maps in P5??? - it is possible in eclipse, but... 2) how to work with the R.java which is linked with the mapView (i have tried to put some .xml for that in the data folder but it does not work and programming i can only set the width and height args, not the mapView.LayOut iself :: R....@id) thanks
sorry, change the line "11" with:
googleMaps = "http://maps.google.com/maps/api/staticmap?center=45.464160,9.191614&zoom=3&size=400x400&sensor=true&markers";
dear camperos, of course i know, it works: see my code! --- but that is a static map!---what to do if the user drag (and he will)??? - Knowing that googlemaps is not multithreaded? thanks!!!
akenaton,
Just to clarify, the loadImage(fileName) method does work in Android, but the loadImage(fileName, extension) does not. It might be, we simply need to change this in Unfolding. Will come back to you in the next days.
dear tn,
i dont understand ; in res/ there are not any extension but if you put the image in the classic data folder it runs normally:
deat tn,
excuse me, i understand now only what you explained & i agree with you; though i cannot see your java sources in the downloaded zip i think that your tileloader uses some method as "loadImage "thisimage", ".png") which of course is not the processing standard loadImage method... That is the reason why the sketch is correctly builded (on android) correctly installed and fails only after starting on the emulator, at the draw ()method. thanks and reguards
i have tried to write some code only to undestand what happens, but i cannot undestand why this code works with java mode and fails in the emulator (not compiling or installing or starting) - console tells (android mode) :: java.lang.NullPointerException at processing.core.PGraphics.image(Unknown Source) though the adress seems to be good and the image is loaded when java mode...Why??? here the code:
strange problem //work// link ("http://otile1.mqcdn.com/tiles/1.0.0/map/12/2156/1463.png");
//work// link ("http://b.tile.openstreetmap.org/12/2156/1463.png");
//work // String adresse = ("http://otile1.mqcdn.com/tiles/1.0.0/map/12/2156/1463.png");
//doesn't work//
String adresse = ("http://b.tile.openstreetmap.org/12/2156/1463.png");
dear camperos,
as for me and using ONLY osm maps (in order to be more simple!)::
1) - in the browser, all the links are working + "http://tile.openstreetmap.org/12/2156/1463.png") [without subdomains]
2 )- java mode, with the above code: they work also
3) - android : java.lang.NullPointerException at processing.core.PGraphics.image(Unknown Source) ?????!!!!!!
(and of course in the manifest internet allowed)
OT: I also at the same time to your work I was looking for a system processing and arduino gps map in real time. I am currently trying with "Atlas Creator" and: http://processingjs.org/learning/basic/mousefunctions/, http://processing.org/examples/scaleshape, http://forum.processing.org/one/topic/mapping-gps-locations-to-a-2d-u-s-map.html
dear camperos, i have tried your code; it compiles, starts and runs. But of course i cannot see your map; i have tried in my code with lat and long == your init values for mapX & mapY and i can see a map (africa???) - but when i tried to put the same map in YOUR code (with MY loadImage(adresse) method (changing of course lat and long) the map disappears, without any error message (and the buttons & text are ok)...Till now i get no explanation for that...See you later!!!
PS: for getting the lat & long while dragging, i have found the same solution (mapping mouse values and coord)
dear camperos, dear tn,
-As for downloading the maps i am now sure that: ----the url used by openstreet maps or others (rows & col &zoom)+.png which work in java mode DOES NOT WORK in android - processing mode: why, i cannot understand. ----on the contrary the url for google maps (statics) does not work in java mode if you dont add "&.png" at the end of the query. ----but in android mode they only work without this .png (or .jpeg or...)
--- dear camperos:: your scale() i think is not good:: you dont change the loaded map ----and i don t understand your translate in push matrix();
so in this moment here is the code i use for getting maps from google. of course i have now to do the real job! [REAL TIME COORDs with ketai lib, saving markers, adding pictures and links!!!][bu, as we say in french language:: "à chaque jour suffit sa peine"]-- tell me if it "works" for you.....thanks & greetings
///at the beginning:: center(!!!) of corsica,where i live and that s the aim of the app
// this library works well with android
///demarre is for the very beginning but i ll change that
/// translating pix into lat or long with map
///if somebody tries it, tell me, thanks!
Dear Akenaton the problem is google because it blocks my IP after some request
dear Camperos,
As for me it does not block; perhaps because i have got a key on their site (and add it in the manifest file)??? - try to get one...But the best solution would be to use openSreetMaps, what i am unable to do, though knowing the exact url for the lat and long of the map (see above the code i have written for getting that). So i continue with googleMaps...In this moment i have found a new problem (which i thought easy to solve!!!) ::: when you "transform" pixels to lat or long with mapping, the values are not really exact. Till you dont zoom, that does not matter, but in my app i have to zoom in at least at level 17, or 18 (20 is the max i believe) and at zoom level 18 the little differences in the values become very important. Is it necessary to use some mercator projection to be absolutely precise???- As i have to work with "little map" (map of corsica ) i think that mercator is not necessary. but perhaps i am wrong!
I must tell you that i do know java (and had a look to android APIS) but with processing android mode i am a new bye. Example: in java mode the width of the display is what you announce in the setup() but is it the same with android mode??? the 4 zones right left bottom and top are they included or not??? - As for mapping with mouseEvents that is important to know. If you can tell me, thank in advance!
best wishes