@@ -39,6 +39,7 @@ class MapIntentBuilder(private vararg var types: MapTypes) : BaseActivityBuilder
3939 private var startLatitude: Double? = null
4040 private var startLongitude: Double? = null
4141 private var isDrivingModeEnabled: Boolean = false
42+ private var isPositioningEnabled: Boolean = false
4243
4344 /* *
4445 * Set a latitude.
@@ -115,8 +116,14 @@ class MapIntentBuilder(private vararg var types: MapTypes) : BaseActivityBuilder
115116 return this
116117 }
117118
118- fun enableDrivingMode () {
119+ fun enableDrivingMode (): MapIntentBuilder {
119120 isDrivingModeEnabled = true
121+ return this
122+ }
123+
124+ fun enablePositioning (): MapIntentBuilder {
125+ isPositioningEnabled = true
126+ return this
120127 }
121128
122129 override fun createIntent (context : Context ) =
@@ -180,7 +187,10 @@ class MapIntentBuilder(private vararg var types: MapTypes) : BaseActivityBuilder
180187 if (startLatitude != null && startLongitude != null ) {
181188 if (isDrivingModeEnabled) sb.append(" google.navigation:q=" , latitude, " ," , longitude)
182189 else sb.append(" http://maps.google.com/maps?saddr=${startLatitude} ,${startLongitude} &daddr=${latitude} ,${longitude} " )
183- } else {
190+ } else if (isPositioningEnabled && latitude != null && longitude != null ) {
191+ sb.append(" http://maps.google.com/maps?daddr=" , latitude, " ," , longitude)
192+ }
193+ else {
184194 if (viewType == null ) {
185195 sb.append(" geo:" )
186196 if (latitude != null && longitude != null ) {
@@ -207,6 +217,8 @@ class MapIntentBuilder(private vararg var types: MapTypes) : BaseActivityBuilder
207217 sb.append(" yandexmaps://" , " maps.yandex.ru/?" )
208218 if (startLongitude != null && startLatitude != null ) {
209219 sb.append(" rtext=" , startLatitude, " ," , startLongitude, " ~" , latitude, " ," , longitude)
220+ } else if (isPositioningEnabled) {
221+ sb.append(" rtext=~" , latitude, " ," , longitude)
210222 } else {
211223 if (latitude != null && longitude != null ) {
212224 sb.append(" pt=" )
@@ -296,6 +308,7 @@ class MapIntentBuilder(private vararg var types: MapTypes) : BaseActivityBuilder
296308 it.startLongitude = startLongitude
297309 it.zoom = zoom
298310 it.viewType = viewType
311+ it.isPositioningEnabled = isPositioningEnabled
299312 }
300313 .createIntentHandler(context)
301314 result + = intentHandler
0 commit comments