Created
February 18, 2017 13:56
-
-
Save lukaskollmer/a2fd3da161903d75e319bea93ac3a2ad to your computer and use it in GitHub Desktop.
Scripter Map View example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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