Skip to content

Instantly share code, notes, and snippets.

@lukaskollmer
Created February 18, 2017 13:56
Show Gist options
  • Select an option

  • Save lukaskollmer/a2fd3da161903d75e319bea93ac3a2ad to your computer and use it in GitHub Desktop.

Select an option

Save lukaskollmer/a2fd3da161903d75e319bea93ac3a2ad to your computer and use it in GitHub Desktop.
Scripter Map View example
const ui = require("ui");
const mapkit = require("mapkit");
const location = require("location");
let view = new ui.View();
let mapView = new mapkit.MapView();
mapView.backgroundColor = new ui.Color("red");
mapView.showsUserLocation = true;
mapView.mapType = mapkit.MapType.hybridFlyover;
mapView.autoresizingMask = ui.AutoresizingMask.flexibleWidth | ui.AutoresizingMask.flexibleHeight;
view.addSubview(mapView);
view.present();
location.geocode("Wolfratshauser Straße 30 82049 Pullach im Isartal Deutschland", (err, placemark) => {
if (err) {
console.log("Error geocoding address:", err);
return;
}
let coordinates = placemark.location.coordinate;
// Focus on region
let mapRegion = new mapkit.CoordinateRegion(coordinates, 500, 500);
mapView.region = mapRegion;
// Add pin
let annotation = new mapkit.Annotation(coordinates, "School", "ugh");
mapView.addAnnotation(annotation);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment