Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created October 2, 2019 15:59
Show Gist options
  • Save AppWerft/03b5159f339b739e6da1a6e4d741700c to your computer and use it in GitHub Desktop.
Save AppWerft/03b5159f339b739e6da1a6e4d741700c to your computer and use it in GitHub Desktop.
module.exports = function() {
var $ = Ti.UI.createView({
backgroundColor : BLUE
});
const Map = require("ti.map");
var mapView = Map.createView({
bottom : 0,
userLocation : Ti.Geolocation.locationServicesEnabled ? true : false,
region : {
latitude : 53.5535071,
longitude : 9.9899668,
latitudeDelta : 0.01,
longitudeDelta : 0.01
},
mapType : Map.NORMAL_TYPE,
mapToolbarEnabled : false,
style : Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "model", "mapstyle.json").read().getText(),
enableZoomControls : false
});
var marker = Map.createAnnotation({
latitude : 53.0,
longitude : 10.0,
image : "/assets/images/null.png",
title : "Lade …",
rightButton : "/assets/wiki.png"
});
mapView.addAnnotation(marker);
mapView.addEventListener("complete", function() {
mapView.addTileOverlay(Map.createTileOverlay({
service : Map.TILE_OVERLAY_TYPE_WMTS,
debuglevel : 2,
url : 'http://wxs.ign.fr/choisirgeoportail/geoportail/wmts',
layer : 'CADASTRALPARCELS.PARCELS',
style : 'normal',
version : '1.0.0',
format : 'image/png',
tilematrixset : 'PM'
}));
mapView.addTileOverlay(Map.createTileOverlay({
service : Map.TILE_OVERLAY_TYPE_WMTS,
debuglevel : 2,
url : 'http://wxs.ign.fr/choisirgeoportail/geoportail/wmts',
layer : 'GEOGRAPHICALGRIDSYSTEMS.MAPS',
style : 'normal',
version : '1.0.0',
format : 'image/jpeg',
tilematrixset : 'PM'
}));
mapView.addTileOverlay(Map.createTileOverlay({
debuglevel : 1,
service : Map.TILE_OVERLAY_TYPE_XYZ,
zIndex : 10,
name : "OpenSeaMap"
}));
mapView.addTileOverlay(Map.createTileOverlay({
debuglevel : 1,
service : Map.TILE_OVERLAY_TYPE_WMS,
url : "http://geodienste.hamburg.de/HH_WMS_Cache",
layer : "strassenbaum",
zIndex : 99,
format: "image/png",
version : "1.1.1",
}));
//mapView.addTileOverlay(Map.createTileOverlay({
// url : "http://geodienste.hamburg.de/HH_WMS_Strassenbaumkataster",
// layer : "strassenbaum_hpa",
// version : "1.3.0",
// }));
mapView.addEventListener("click", function(e) {
console.log(e.clicksource);
if (e.clicksource == "rightPane" && e.annotation && e.annotation.species) {
require("wiki.window")(e.annotation.species.replace("europea", "europaea").replace(" x ", " × ")).open();
}
});
mapView.addEventListener("mapclick", function(e) {
marker.latitude = e.latitude;
marker.longitude = e.longitude;
marker.title = " Lade … ";
marker.subtitle = "";
Log("mapclick");
var trees = require("store").getNearestTree(e.latitude, e.longitude);
if (!trees || !trees[0]) {
mapView.deselectAnnotation(marker);
Ti.UI.createNotification({
message : "Für diesen Standort gibt es leider keine Bauminformationen."
}).show();
return;
}
var tree = trees[0];
Log("found tree nearby " + tree.leaf);
marker.title = tree["sorte_latein"];
marker.subtitle = tree["sorte_deutsch"] + " (" + tree.pflanzjahr + ")";
marker.latitude = tree.latitude;
marker.longitude = tree.longitude;
marker.leftButton = tree.leaf;
marker.species = tree["art_latein"], mapView.selectAnnotation(marker);
});
});
$.add(mapView);
return $;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment