Select to view content in your preferred language

Displaying Current Location on MAP, not Working (when Tiled Layer not added)

6912
11
05-20-2015 12:37 PM
GajaNaik
Deactivated User

Hi,

no code changes nothing, MyLocation is displayed on MAP when Tiled Layer is added as Base MAP, but when there is no Tiled Layer / Blank with Dynamic Layer , current/My Location  can not be seen (Blue Dot).

its basic code and was working earlier, was notice recently that only without Tiled Layer user can not see Location on MAP... but works fine with Tiled Layer....

11 Replies
MengyiGuo
Deactivated User

I have your issue reproduced but I want to make sure how did you display your location? Is the code as follows?

[self.mapView.locationDisplay startDataSource];

self.mapView.locationDisplay.autoPanMode = AGSLocationDisplayAutoPanModeDefault;

If so, I think the behavior you reported is as designed. Because in the API reference of AGSLocationDisplay Class, it says:

To make the map start displaying location information, use the startDataSource method, but ensure the map is loaded successfully before you do..

0 Kudos
GajaNaik
Deactivated User

               if(!self.mapView.locationDisplay.dataSourceStarted)

                    [self.mapView.locationDisplay startDataSource];

              

                //Listen to KVO notifications for map scale property

                [self.mapView addObserver:self

                                 forKeyPath:@"mapScale"

                                    optionsNSKeyValueObservingOptionNew)

                                    context:NULL];

                //AGSGPSAutoPanModeCompassNavigation

                self.mapView.locationDisplay.autoPanMode = AGSLocationDisplayAutoPanModeCompassNavigation  ;

                self.mapView.locationDisplay.navigationPointHeightFactor  = 0.5;

code is same as that of Sample code "GpsSampleViewController"  of ESRI and i verified with rest online example's,

. also MyLocation is like Btn(Apart from displaying Location on Start of Page), user can Click anytime after MAP is loaded. so MAP is already loaded.

this behaviour notice recently may be after IOS 7 i guess, earlier was working just fine.

Now also same code work very well when Tiled MAP added,

only to user with out TiledMAP/ Blank MAP Location is not Displayed. (Blue Dot).

0 Kudos
DavidLednik
Frequent Contributor

Hi Gaja,

Didn't test this but there's one quick workaround I can think of.

Instead of removing tiled layer, set it's opacity property to 0.

It will not be drawn and it will not request tiles from the server but location display should keep working.

And when you replace your base map simply change tiled layer opacity back to 1. Should make no difference to end user experience.

David

0 Kudos
GajaNaik
Deactivated User

Hello,

with opacity = 0 of tiled layer when user do not have tiled layer does show the current location, blue Dot.

as of now when i set property to 0, rest stuff like output spatial reference n all need to be same way when property is set to 1, and only diff will be property value?. there are lots of search and rest feature been used, m worried about something may fail...

since this is workaround it might fail something,  then 1 workaround to adjust have to adjust rest too....

i guess this is an issue current location not visible without TiledLayer ....  as it was woking earlier ...

0 Kudos
DavidLednik
Frequent Contributor

Yes that is correct. The only "issue" you will have is when spatialReferences (SR) are not the same. In which case you would have to reload the map with basemap that has same SR as operational layers. But that is how map is designed. Once the SR is set it can only be changed if you recreate the map with new data.

I'll test this in the new release once location is implemented to check the behaviour of the new API. I can let you know how it turns out if you're interested to explore new beta functionality once it's released as beta.

David

0 Kudos
GajaNaik
Deactivated User

Hello,

as i had mentioned i landed up in 1 issue which i had asked other day, now realise was because of above workaround.

plz let me know once u r done with above mentioned issue...so that i can test and stop further workaround....

0 Kudos
DavidLednik
Frequent Contributor

Hi!

Sorry for the late reply. I was away for two weeks.

I'm not exactly sure what you mean. Can you please describe again what issue do you have with the suggested workaround?

David

0 Kudos
GajaNaik
Deactivated User

Hello!

yes whats happened is because of my original issue,

Displaying Current Location on MAP, not Working (when Tiled Layer not added)

and as workaround for above problem i added Tiled Layer and set opacity to 0.

but we keep layer info once loaded(mapViewDidLoad) to global class which is used time to time either for zooming or so....like Envelope, SpatialReference ETC.

as we never used to add Tiled Layer earlier , information getting saved of that of Dynamic Layer considering that was 1st layer loaded.

but now what happens is Tiled Layer which i have added and whose Opacity is 0, in mapViewDidLoad since it becomes 1st layer ..... Tiled Layer information get saved (our Global Class)....like Envelope, SpatialReference ETC.

when we used at different point this get mismatch..... like when zoom ,it zoom out according to Tiled Layer and not Dynamic Layer Envelope(since we have added Tiled it saved Tiled MAP INFO. i have to change it to save Dynamic Layer),....also when we search we need to adjust output SpatialReference specially searching Assets n all.....(executeWithQuery)

its like we do not want Tiled Layer , but have to used it ....because otherwise we do not get our Location Display (Blue Dot). since we have to used it need all workaround to be done , other wise would not have required if we could see Current Location on MAP with out Tiled Layer..... it was working earlier fine now only the issue with ESRI SDK...

0 Kudos
DavidLednik
Frequent Contributor

Thanks for the details.

You could try to move the tiled layer. Once the map is loaded and SR set from tiled layer it can be at any position in the map. So when you add layers you can insert them before the tiled layer. That way it's not going to be the 1st layer in the map if it helps.

I tested this in our latest build and locationDisplay is working on empty map as long as it has a valid spatial reference. In this case map was initialised with WGS84 SR and no layers.

regards,

David

0 Kudos