Discussion Forums  >  Maps, Device Location, Tracking

Replies: 6    Views: 254

vtad
Aspiring developer
Profile
Posts: 40
Reg: Nov 17, 2013
Jettingen
8,700
04/17/14 08:56 AM (10 years ago)

Location Map plugin, initial Zoom factor

Environment: Android 4.1.2, BT V3, google Maps API V2 Works fine, but how can I set the initial Zoom - its at max, "Single Location Default Zoom (1-28)" seems to have no effect.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
04/17/14 11:10 AM (10 years ago)
I have never been able to set it explicitly, but I have noticed on my app that has a map with 19 pins representing F1 circuits worldwide that it starts off as the most zoomed out it could be - i.e. a map of the world.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/17/14 03:58 PM (10 years ago)
How odd; you're right. I took a quick snoop through the code, and although it will grab the data for SingleLocationDefaultZoom, it doesn't actually 'do' anything with it. "Typically" what happens is, like AlanMac mentioned, is it will 'self zoom' to encompass all Pins (points of interest) on the map… Unless overridden by the SLDZ. I won't 'guarantee' this will work; I haven't tested it. But it 'looks' like it should help… Around line 527 of your 'BT_screen_map.java' file you'll see these statements: mapView.getUiSettings().setCompassEnabled(true); mapView.getUiSettings().setZoomControlsEnabled(true); in a method called 'setMapBounds'. AFTER Those two statements, add this: Float myZoom = Float.parseFloat(singleLocationDefaultZoom); // step 1 mapView.animateCamera(CameraUpdateFactory.zoomTo(myZoom)); // step 2 What we're doing is: 1) Declaring a float variable, naming it 'myZoom', and assigning it a float value created by converting a string "singleLocationDefaultZoom". 2) telling the 'camera' (in 'Google Land' we're looking at the map from behind the lens of a big camera in the sky) to zoom to the new zoom level. At least, that's the intention. Let me know how it works out for you. Cheers! -- Smug
 
vtad
Aspiring developer
Profile
Posts: 40
Reg: Nov 17, 2013
Jettingen
8,700
like
04/18/14 06:28 AM (10 years ago)
@smugwimp I set the Single Location Default Zoom = 1, added myZoom: strange effect, the first time I call the map it shows the location with a size of more or less 400 Km wide, calling the map again shows southwest from Africa mit a similar zoom. In the log I got (after the second call) ..... V/LocationManagerService(459): getAllProviders E/LocSvc_eng(459): I/===> int loc_eng_update_criteria(loc_eng_data_s_type&, UlpLocationCriteria) line 1923 04-18 15:09:30.230: V/LocationManagerService(459): In requestLocationUpdates. provider gpsminTime: 5000single shot: false Listener: android.location.ILocationListener$Stub$Proxy@41a3adc0 04-18 15:09:30.230: V/LocationManagerService(459): _requestLocationUpdates: provider = gps listener = Receiver{41a4df00 Listener android.os.BinderProxy@41df0988}mUpdateRecords: {gps=UpdateRecord{4163cc48 mProvider: gps mUid: 10009}} 04-18 15:09:30.240: W/InputMethodManagerService(459): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41bcc3d8 attribute=android.view.inputmethod.EditorInfo@419bef40
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/18/14 07:24 AM (10 years ago)
Well, I wasn't entirely sure if it would work; I think I'm close though. It's almost bed time; I'll try and take a look when I get behind the keyboard tomorrow, and will work on 'real' code and test it before I suggest a solution. For the time being, just 'undo' what you've done; no need to bring errors into the mix. Cheers! -- Smug
 
vtad
Aspiring developer
Profile
Posts: 40
Reg: Nov 17, 2013
Jettingen
8,700
like
04/18/14 07:31 AM (10 years ago)
Thx for your help, in between I found something like a workaround setting the default map type to "terrain". But, as you stated, "singleLocationDefaultZoom" is ignored. Goodn8
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
04/18/14 08:50 AM (10 years ago)
Hey Smug, I'm experimenting with the properties of the code you listed above, but not using a pre-made plugin... just adding a UIMap object to a view. I can't seem to figure out how to set the zoom that way. Any suggestions? And somewhat off topic.... Call be oblivious, since I'm still learning Xcode, but when I create an object on an XIB, for example, the UIMap object... how to I know (or assign) the object's name? I looked through all of the attributes, and only see the type... and the name of the object is not declared in the headers, beacause it was created using drag and drop with interface builder. I guess it's one of those little simple things that I never picked up when I was learning xcode, lol. For example, if I want to add some code to to change the border or something, I'd use something like nameMap.border=1.... but where does the nameMap part get defined when the object is created in IB?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.