+1
Answered
Location update for action
I am tinkering around with some location based ideas and I need to be able to tell when the current location has been updated (i.e. when the user/device has moved from one set of GPS coordinates to another). I see that there is a datasourceevent attribute named "locationupdate" that is currently still in beta.
When will that feature be out of beta? Can you provide a quick example of how it should be used?
My code so far:
I am not entirely certain I am using it correctly. Thank you for any help!
When will that feature be out of beta? Can you provide a quick example of how it should be used?
My code so far:
<action name="updatedlocation" datasource="annotations" datasourceevent="locationupdate">
<assign property="object:LABEL.text" value="[object:MAP.gpslocation]"/>
<alert message="Location changed!" />
</action>
I am not entirely certain I am using it correctly. Thank you for any help!
Customer support service by UserEcho
This feature is available in the WIRE engine 1.3, so we should be able to get it working for you.
<datasource name="Geo" source="standard" query="location" distanceFilter="1" providertype="location"/>
and my map to this:
<map name="map" alias="MAP" width="100%" height="100%" datasource="Geo" currentlocation="yes" showuser="yes">
</map>
With this action:
<action name="updatedlocation" datasource="Geo" datasourceevent="locationupdate">
<alert message="Location changed!" />
</action>
It still doesn't work as I expected it would, but again I am not certain I am using it/understanding it correctly. I am assuming that if the user moves far enough (in this case a maximum of 1 meter) it would trigger the iOS library to send a location update to the datasourceevent listener(?) which would then trigger my action. Forgive me, I am pretty new to location based stuff (which is why I was tinkering).
I am testing on my wife's iPhone 4/iOS6.
Any chance you have an example of some working code so I can see where I am going wrong?
Thank you for your help!
First, change your source on the datasource from standard to Significant-Change.
Then you will also want to turn on your location tracking on the datasource. For testing you can just add it to the datasource as location="yes". This will drain the battery on the device if you leave it on all the time, so you probably only want to turn it on when you show the map or something and turn it off when you navigate away. See the assign below.
<assign property="datasource:Geo.location" value="on" />
<wire>
<datasources>
<datasource name="Geo" source="significant-change" location="yes" query="location" providertype="location"/>
</datasources>
<main>
<map name="map" alias="MAP" width="100%" height="100%" datasource="Geo" currentlocation="yes" showuser="yes"></map>
</main>
<actions>
<action name="setmaplocation" oninit="yes">
<assign property="object:MAP.region" value="[object:MAP.gpslatitude] [object:MAP.gpslongitude] [object:MAP.gpslatitude] [object:MAP.gpslongitude]"/>
</action>
<action name="updatedlocation" datasource="Geo" datasourceevent="locationupdate">
<alert message="Location changed!" />
</action>
</actions>
</wire>
Here is a sample that works: