Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mapbox sdk + gsimap (kotlin)
package org.smellman.mapboxsdktest
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.mapbox.mapboxsdk.api.ILatLng
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.tileprovider.tilesource.WebSourceTileLayer
import com.mapbox.mapboxsdk.views.MapView
public class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val mv:MapView = findViewById(R.id.mapview) as MapView
mv.setTileSource(WebSourceTileLayer("gsi_std","http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png"))
val defaultCenter:ILatLng = LatLng(35.362222, 138.731389)
mv.setCenter(defaultCenter)
val defaultZoom:Float = 5f
mv.setZoom(defaultZoom)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.menu_main, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
val id = item.itemId
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true
}
return super.onOptionsItemSelected(item)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment