map and markers added

This commit is contained in:
simon 2020-08-20 20:06:48 +03:00
parent 074e36f8ae
commit 122d77f205
14 changed files with 15248 additions and 282 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

Binary file not shown.

View file

@ -1,17 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OsmAnd - Offline Mobile Maps and Navigation</title>
<link rel="stylesheet" type="text/css" href="/css/site.css?v=4"/>
<!-- <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet.js"></script>
<script type="text/javascript" src="/scripts/jquery-3.1.0.min.js"></script>
<!--
@ -19,6 +19,39 @@
-->
<script type="text/javascript" src="/scripts/js.cookie.js"></script>
<script>
function getMarkerContent(feature) {
var p = feature.properties;
var popupContent = p.title;
if(p.opr_id) {
popupContent += " (" + p.opr_id+") ";
}
if(p.tags) {
for (var t in p.tags) {
popupContent += "<br>" + t + " " + p.tags[t];
}
}
if(p.opr_id) {
popupContent += "<br><a href=\'/api/admin?view=objects&browse=type&type=opr.place&subtype=id&key=" +
p.opr_id + "\'>OpenPlaceReviews</a>";
}
if(p.osm_id) {
popupContent += "<br><a href=\'https://www.openstreetmap.org/" +
p.osm_type + "/" + p.osm_id + "\'>OpenStreetMap</a>";
}
return popupContent;
}
function setupMarkers(){
var points = window.osmand.favoritePoints;
points.forEach(e => {
var point = {};
point.lat = e.latitude;
point.lon = e.longitude;
window.goMap.map.addMarker(point);
})
}
</script>
<script type="text/javascript" src="/scripts/go.js?v=5"></script>
</head>
<body>
@ -36,11 +69,13 @@
<div class="gobadges">
<div class="badgecontainer google">
<a href="https://play.google.com/store/apps/details?id=net.osmand.plus">
<img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png">
<img alt="Get it on Google Play"
src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png">
</a>
</div>
<div class="badgecontainer apple">
<a href="https://itunes.apple.com/us/app/id934850257"><img src="images/app-store-badge.png"></a>
<a href="https://itunes.apple.com/us/app/id934850257"><img
src="images/app-store-badge.png"></a>
</div>
<div class="badgecontainer amazon">
<a href="http://www.amazon.com/gp/product/B00D0SEGMC/ref=mas_pm_OsmAnd-Maps-Navigation">

View file

@ -1,238 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>BootsApp | Home</title>
<style>
</style>
</head>
<body>
<a onclick="window.location.href = '/button1Click';">
<button style="text-align: center;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
CLICK ME TO SHOW TOAST
</button>
</a>
<nav class="navbar navbar-expand-md bg-secondary navbar-dark fixed-top shadow">
<a class="navbar-brand" href="#">LOGO </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="#"><i class="fas fa-home fa-lg d-md-none pr-2 "></i>Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html"><i class="fas fa-info-circle fa-lg d-md-none pr-2"></i> About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pricing.html"><i class="fas fa-rupee-sign fa-2x d-md-none pr-2"></i> Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.html"><i class="fas fa-user fa-lg d-md-none pr-2"></i> Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="signup.html"><i class="fas fa-edit fa-lg d-md-none pr-2"></i>Signup</a>
</li>
</ul>
</div>
</nav>
<div class="container header">
<div class="jumbotron">
<div class="header-content mt-4">
<h2 class="display-2">Company Inc.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ut unde quaerat consequatur?</p>
<a href="login.html" class="btn btn-primary">Get Started</a>
</div>
</div>
</div>
<div class="container features">
<h2 class="text-center mb-4">Our Speciality</h2>
<div class="row">
<div class="col-md-4 col-sm-12 p-2 shadow-sm text-center spec">
<i class="fas fa-tablet-alt fa-2x mb-2"></i>
<h4>Device Compatible</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo, doloremque voluptatum. Ducimus.</p>
</div>
<div class="col-md-4 col-sm-12 shadow-sm text-center spec">
<i class="fas fa-cloud fa-2x mb-2"></i>
<h4>Cloud Support</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo, doloremque voluptatum. Ducimus.</p>
</div>
<div class="col-md-4 col-sm-12 shadow-sm text-center spec">
<i class="fas fa-phone fa-2x mb-2"></i>
<h4>24/7 Call Support</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo, doloremque voluptatum. Ducimus.</p>
</div>
</div>
</div>
<div class="container products">
<h2 class="text-center mb-4">Our Products</h2>
<div class="row mt-4 p-4">
<div class="col-md-5 col-sm-12">
<img src="https://images.unsplash.com/photo-1501959181532-7d2a3c064642?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9ffb47d2c8a236bae5e5bb86b2c400b9&auto=format&fit=crop&w=1070&q=80" style="height: 100%;width: 100%;" alt="product-image" class="shadow-lg">
</div>
<div class="col-md-7 col-sm-12 mt-sm-4" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Velit nobis officiis unde necessitatibus esse alias expedita quia doloremque assumenda. Cupiditate nam exercitationem voluptatem quidem ad dolore ullam aliquid culpa ducimus qui, ut dignissimos inventore veniam!</p>
</div>
</div>
<div class="row mt-4 p-4 hide-on-sm">
<div class="col-md-7 col-sm-12 mt-sm-4" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Velit nobis officiis unde necessitatibus esse alias expedita quia doloremque assumenda. Cupiditate nam exercitationem voluptatem !</p>
</div>
<div class="col-md-5 col-sm-12">
<img src="https://images.unsplash.com/photo-1517694712202-14dd9538aa97?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a20bc6324f6ef2969d9a7cae56b8d4d1&auto=format&fit=crop&w=1050&q=80" style="height: 100%;width: 100%;" alt="product-image" class="shadow-lg">
</div>
</div>
<div class="row mt-4 p-4">
<div class="col-md-5 col-sm-12">
<img src="https://images.unsplash.com/photo-1512486130939-2c4f79935e4f?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=dfd2ec5a01006fd8c4d7592a381d3776&auto=format&fit=crop&w=800&q=80" style="height: 100%;width: 100%;" alt="product-image" class="shadow-lg">
</div>
<div class="col-md-7 col-sm-12 mt-sm-4" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Velit nobis officiis unde necessitatibus esse alias expedita quia doloremque assumenda. Cupiditate nam exercitationem voluptatem quidem ad dolore ullam aliquid culpa ducimus qui, ut dignissimos inventore veniam!</p>
</div>
</div>
<div class="text-center"><a href="#" class="btn btn-default text-center">View more</a></div>
</div>
<div class="container">
<h2 class="text-center mb-4">Our Customers</h2>
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="row mt-4 p-4">
<div class="col-md-5 col-xs-12 mt-sm-2">
<img src="https://images.unsplash.com/photo-1497215842964-222b430dc094?ixlib=rb-0.3.5&s=76fbdf2a268252eb9d7c7dbd55f445dc&auto=format&fit=crop&w=1050&q=80" style="height: 100%;width: 100%;" alt="product-image">
</div>
<div class="col-md-7 col-xs-12" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit.nam exercitationem voluptatem quidem ad dolore ullam aliquid culpa ducimus qui, ut dignissimos inventore veniam!<br>
<cite class="small">~ George Henry, <span class="text-muted">Lead Engineer Fast Labs</span></cite></p>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row mt-4 p-4">
<div class="col-md-5 col-xs-12">
<img src="https://images.unsplash.com/photo-1434626982825-b030fb94f5be?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=862c021c4fa3b0255cc666fafc5dbfdc&auto=format&fit=crop&w=1053&q=80" style="height: 100%;width: 100%;" alt="product-image">
</div>
<div class="col-md-7 col-xs-12 mt-sm-2" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Velit nobis officiis unde necessitati fafe gnissimos inventore veniam!<br>
<cite class="small">~ John Anderson, <span class="text-muted">CTO Acme Tech.</span></cite></p>
<!-- <blockquote class="blockquote text-left">
<p class="mb-0">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea magnam, possimus sed ex deleniti facere? Quidem dignissimos blanditiis ut sequi accusantium necessitatibus. Aperiam?</p>
<footer class="blockquote-footer"> <cite title="Source Title">Source Title</cite></footer>
</blockquote> -->
</div>
</div>
</div>
<div class="carousel-item">
<div class="row mt-4 p-4">
<div class="col-md-5 col-xs-12">
<img src="https://images.unsplash.com/photo-1525332193053-dee9e7348624?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a171c64a1cb121a923c4e95d8308ca9e&auto=format&fit=crop&w=1050&q=80" style="max-height: 100%;max-width: 100%;" alt="product-image">
</div>
<div class="col-md-7 col-xs-12 mt-sm-2" style="display:flex;align-items:center;">
<p class="lead">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Velit nobis officiis unde necessitatibus esmos inventore veniam!<br>
<cite class="small">~ Ishaan Sheikh, <span class="text-muted">CEO Sigma Inc.</span></cite></p>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div class="container-fluid bg-primary p-4 mt-4 last-sec">
<div class="text-center">
<h2 class="display-4 text-white">Ready to get started</h2>
<a href="login.html" class="btn btn-dark btn-lg mt-2">Try it for free</a><br>
</div>
</div>
<!-- <div style="height: 500px;"></div> -->
<div class="container-fluid bg-dark text-white pb-4">
<div class="row p-4">
<div class="col-md-4 col-sm-12 text-center">
<ul class="list-unstyled">
<li class="list-header" style="font-size: 1.5rem;">Developer</li>
<li><div class="divider bg-light" ></div></li>
<li><a href="#" class="btn text-white">Developer's API</a></li>
<li><a href="#" class="btn text-white">Get Your API key</a></li>
<li><a href="#" class="btn text-white">OAuth Key</a></li>
<li><a href="#" class="btn text-white">Pricing</a></li>
</ul>
</div>
<div class="col-md-4 col-sm-12 text-center">
<ul class="list-unstyled ">
<li class="list-header" style="font-size: 1.5rem;">Support</li>
<li><div class="divider bg-light" ></div></li>
<li><a href="#" class="btn text-white">Troubleshoot</a></li>
<li><a href="#" class="btn text-white">Questions</a></li>
<li><a href="#" class="btn text-white">Report a bug</a></li>
<li><a href="#" class="btn text-white">Help</a></li>
</ul>
</div>
<div class="col-md-4 col-sm-12 text-center">
Follow us on
<ul class="list-unstyled list-inline social-icons mt-1">
<li class="list-inline-item"><a href="#"><i class="fab fa-2x fa-facebook-square"></i></a> </li>
<li class="list-inline-item"><a href="#"><i class="fab fa-2x fa-google"></i></a> </li>
<li class="list-inline-item"><a href="#"><i class="fab fa-2x fa-twitter-square"></i></a> </li>
<li class="list-inline-item"><a href="#"><i class="fab fa-2x fa-instagram"></i></a> </li>
<li class="list-inline-item"><a href="#"><i class="fab fa-medium fa-2x"></i></a></li>
</ul>
</div>
</div>
<div class="text-center">
<span class="fas fa-code text-primary"></span>&nbsp;&nbsp;with&nbsp;&nbsp;<span class="fas fa-heart" style="color: red"></span> By Developers<br>
2018 &copy; Developers.com<br>
The images are taken from <a href="https://unsplash.com">Unsplash.com</a> to avoid copyright issues.
</div>
</div>
<script>
// window.sr = ScrollReveal();
// sr.reveal('h2.display-2',{
// duration:2000,
// origin:'left',
// distance:'30px'
// });
// sr.reveal('',{
// duration:2000,
// origin:'left',
// distance:'30px'
// });
</script>
</body>
</html>

View file

@ -73,7 +73,7 @@ public class ServerActivity extends AppCompatActivity {
OsmAndHttpServer.HOSTNAME = getDeviceAddress();
try {
server = new OsmAndHttpServer();
server.setAndroidContext((OsmandApplication)this.getApplication());
server.setAndroidApplication((OsmandApplication)this.getApplication());
initialized = true;
updateTextView("Server started at: http://" + getDeviceAddress() + ":" + OsmAndHttpServer.PORT);
} catch (IOException e) {

View file

@ -3,6 +3,9 @@ package net.osmand.plus.server;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.google.gson.Gson;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.OsmandApplication;
import java.io.BufferedReader;
@ -10,6 +13,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.List;
import fi.iki.elonen.NanoHTTPD;
@ -22,20 +26,47 @@ public class ApiRouter {
return androidContext;
}
private final String FOLDER_NAME = "server";
private Gson gson = new Gson();
public void setAndroidContext(OsmandApplication androidContext) {
this.androidContext = androidContext;
}
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
Log.d("SERVER", "URI: " + session.getUri());
if (session.getUri().equals("/")) return getStatic("/go.html");
if (session.getUri().contains("/scripts/") ||
session.getUri().contains("/images/") ||
session.getUri().contains("/css/") ||
session.getUri().contains("/fonts/") ||
session.getUri().contains("/favicon.ico")
) {
return getStatic(session.getUri());
) return getStatic(session.getUri());
if (isApiUrl(session.getUri())){
return routeApi(session);
}
else {
return routeContent(session);
}
}
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
return newFixedLengthResponse("");
}
private boolean isApiUrl(String uri) {
return uri.endsWith("/favorites");
}
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
String url = session.getUri();
//add index page
String responseText = getHtmlPage(url);
if (responseText != null) {
responseText = addFavoritesToResponse(responseText);
return newFixedLengthResponse(responseText);
} else {
return getGoHtml();
return ErrorResponses.response404;
}
}
@ -44,8 +75,8 @@ public class ApiRouter {
String mimeType = parseMimeType(uri);
if (androidContext != null) {
try {
is = androidContext.getAssets().open("server" + uri);
if (is.available() == 0){
is = androidContext.getAssets().open(FOLDER_NAME + uri);
if (is.available() == 0) {
return ErrorResponses.response404;
}
return newFixedLengthResponse(
@ -54,7 +85,7 @@ public class ApiRouter {
is,
is.available());
} catch (IOException e) {
return ErrorResponses.response500;
return ErrorResponses.response404;
}
}
return ErrorResponses.response500;
@ -70,12 +101,10 @@ public class ApiRouter {
return type;
}
public NanoHTTPD.Response getGoHtml() {
String responseText = "";
if (androidContext != null) {
try {
InputStream is = androidContext.getAssets().open("server/go.html");
private String readHTMLFromFile(String filename) {
StringBuilder sb = new StringBuilder();
try {
InputStream is = androidContext.getAssets().open(FOLDER_NAME + filename);
BufferedReader br = new BufferedReader(new InputStreamReader(is,
Charset.forName("UTF-8")));
String str;
@ -83,12 +112,37 @@ public class ApiRouter {
sb.append(str);
}
br.close();
responseText = sb.toString();
} catch (IOException e) {
return ErrorResponses.response500;
e.printStackTrace();
return null;
}
return sb.toString();
}
return newFixedLengthResponse(responseText);
public String getHtmlPage(String name) {
String responseText = "";
if (androidContext != null) {
responseText = readHTMLFromFile(name);
}
if (responseText == null) {
return null;
}
return responseText;
}
private String addFavoritesToResponse(String responseText) {
List<FavouritePoint> points = androidContext.getFavorites().getFavouritePoints();
StringBuilder text = new StringBuilder();
for (FavouritePoint p : points) {
String json = jsonFromFavorite(p);
text.append(json);
text.append(",");
}
return responseText + "<script>var osmand = {}; window.osmand.favoritePoints = [" + text.toString() + "];setupMarkers();</script>";
}
private String jsonFromFavorite(FavouritePoint favouritePoint) {
return gson.toJson(favouritePoint);
}
static class ErrorResponses {

View file

@ -3,7 +3,6 @@ package net.osmand.plus.server;
import net.osmand.plus.OsmandApplication;
import java.io.IOException;
import java.util.Map;
import fi.iki.elonen.NanoHTTPD;
@ -12,15 +11,15 @@ public class OsmAndHttpServer extends NanoHTTPD {
public static String HOSTNAME = "0.0.0.0";
private ServerSessionHandler sessionHandler = new ServerSessionHandler();
private OsmandApplication androidContext;
private OsmandApplication androidApplication;
public OsmandApplication getAndroidContext() {
return androidContext;
public OsmandApplication getAndroidApplication() {
return androidApplication;
}
public void setAndroidContext(OsmandApplication androidContext) {
this.androidContext = androidContext;
sessionHandler.setAndroidContext(androidContext);
public void setAndroidApplication(OsmandApplication androidApplication) {
this.androidApplication = androidApplication;
sessionHandler.setAndroidApplication(androidApplication);
}
public OsmAndHttpServer() throws IOException {

View file

@ -5,17 +5,17 @@ import net.osmand.plus.OsmandApplication;
import fi.iki.elonen.NanoHTTPD;
public class ServerSessionHandler {
private OsmandApplication androidContext;
private OsmandApplication androidApplication;
private ApiRouter router = new ApiRouter();
public OsmandApplication getAndroidContext() {
return androidContext;
public OsmandApplication getAndroidApplication() {
return androidApplication;
}
public void setAndroidContext(OsmandApplication androidContext) {
this.androidContext = androidContext;
router.setAndroidContext(androidContext);
public void setAndroidApplication(OsmandApplication androidApplication) {
this.androidApplication = androidApplication;
router.setAndroidContext(androidApplication);
}
public NanoHTTPD.Response handle(NanoHTTPD.IHTTPSession session) {