Code Monkey home page Code Monkey logo

cordova-plugin-mbtiles's Introduction

cordova-plugin-mbtiles 3.4.0

To install plugin

  • Android

create project by cordova

cordova create <project_name> <package_name> <name_class>

Then

cordova platform add android

cordova add plugin <path_to_src>
  • Windows

create project by cordova

cordova create <project_name> <package_name> <name_class>

Then

cordova platform add wp8

cordova add plugin <path_to_src>

After need to istall and add reference SQlite For Windows.

  • iOS

create project by cordova

cordova create <project_name> <package_name> <name_class>

Then

cordova platform add ios

cordova add plugin <path_to_src>
  • BlackBerry

create project by cordova

cordova create <project_name> <package_name> <name_class>

Then

cordova platform add blackberry10

cordova add plugin <path_to_src>

======================

Thanks to @stihl-sicher, to improve the sample with Leaflet 1.0.1, commit :

Commit


cordova-plugin-mbtiles's People

Contributors

ffournier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cordova-plugin-mbtiles's Issues

Sample

Need to push a javascript sample to use it. Just the www resource.

Clean plugin xml

Maybe we can remove the dependencies on file and/or file-transfert.

Pass the type cdvfile into a new enter value in method init

Maybe we can create a new value in method init where we'll have the possibility to choose between the fullPath or cdvfile.

Therefore we can use file or db with the value cdvfile, instead have just db currently.

si init({type: type (db, file), path: path (fullpath, cdvfile), url : url(optional)}, ...)

create branch for this !

Synchronise File FileTransfert and Plugin

Need to test the synchronise between this plugin with different path.

We have a bug on BlackBerry between the fileTransfert and the MbTiles Plugin, need to pass by the URL and not URI to download.

Currently, We not test on Windows Phone 8.

getTiles Error iOS

We 've got an exception in getTiles on ios platform when we ask a tiles out of bounds.

Cordova ios 4.1.1 - Offline Map doesn't show up (MBtiles plugin)

We use the Mbtiles plugin 1.0.0, to show up off-line maps in iOS. Our app worked fine till cordova ios version 4.0.1. WHen we downloaded version 4.1.1 and regerated the app with X-Code (same version 7.3.1) the off-line maps do not show up (they can;t be opened).

Thanks in advance,

--Dimitris Doukas

Native dependencies

Hi, Just a question out of curiosity.

Are there any native features needed by this library or could it be reimplemented as a JavaScript library utilising the CordovaSQLite plugin?

I couldn't see anything obvious, but I may very well have missed something.

Thanks.

Fullpath for Android Sandbox memory

The plugin kept throwing an 'SQLiteCantOpenDatabaseException' when I tried to use the application data directory. I ended up doing this to get it to work:

var store = cordova.file.dataDirectory;
var fpath = store.substring(7, store.length); //remove the 'file://' part
mbTilesPlugin.init({type: type, typepath: 'fullpath', url: fpath}, function(rinit) {
...
});

Sample Progress

Need to put a text in index.html to show download progress

Supporting Leaflet 1.0.1

This plugin works great for Leaflet 0.7
There were major changes in the Leaflet TileLayer in Update to 1.0. Thus, this plugin is not working with Leaflet 1.0.1

I took a closer look to Leaflet and changed the file TileLayer.MBTilesPlugin.js
The function _loadTile is no longer in use. We have to change behaviour of loading tiles in the process of creating tiles.

Here is my working version for Leaflet 1.0.1

L.TileLayer.MBTilesPlugin = L.TileLayer.extend(
{
	mbTilesPlugin : null,
	mbTilesMetadata : null,
	base64Prefix : null,

	createTile: function (coords, done) {
		var tile = document.createElement('img');

		L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile));
		L.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile));

		if (this.options.crossOrigin) {
			tile.crossOrigin = '';
		}

		tile.alt = '';
		tile.setAttribute('role', 'presentation');

		tile.src = this.getTileUrl(coords,tile);

		return tile;
	},

	initialize: function(mbTilesPlugin, options, callback)
	{
		try {
			console.log("initialize");
			this.mbTilesPlugin = mbTilesPlugin;
			L.Util.setOptions(this, options);

			var tileLayer = this;
			var minZoom = 0;
			var maxZoom = 0;

			console.log("initialize2");
			mbTilesPlugin.getMinZoom(function(result)
			{
				console.log("getMinZoom");
				minZoom = result.min_zoom;
				console.log(result);
				console.log("getMinZoom --" + minZoom + "--");
				mbTilesPlugin.getMaxZoom(function(result)
				{
					console.log("getMaxZoom");
					maxZoom = result.max_zoom;
					console.log("getMaxZoom --" + maxZoom + "--");
					mbTilesPlugin.getMetadata(function(result)
					{
						console.log("getMetadata");
						mbTilesMetadata = result;
						console.log(result);
						L.Util.setOptions(tileLayer,
						{
							minZoom: minZoom,
							maxZoom: maxZoom
						});

						if (mbTilesMetadata.format)
						{
							base64Prefix = "data:image/" + mbTilesMetadata.format + ";base64,";
							console.log("base64Prefix --" + base64Prefix + "--");
						}
						else
						{
							// assuming that tiles are in png as default format ...
							base64Prefix = "data:image/png;base64,";
							console.log("base64Prefix --" + base64Prefix + "--");
						}
						callback(tileLayer);
					});
				});
			});
		} catch(e) {
			console.log("initialize "+e.message);
		}
	},

	getTileUrl: function (tilePoint, tile)
	{
		try {
			var z = tilePoint.z; 
			var x = tilePoint.x;
			var y = this._globalTileRange.max.y - tilePoint.y; 
			console.log("getTileUrl");
			console.log(this.mbTilesPlugin);
			console.log("-----");
			this.mbTilesPlugin.getTile({z: z, x: x, y: y},
				function(result)
				{
					tile.src = base64Prefix + result.tile_data;
				},
				function(error)
				{
					console.log("failed to load tile " + JSON.stringify(error));
				});
		} catch(e) {
			console.log("getTileUrl "+e.message)
		};
		return L.Util.emptyImageUrl;
	}
});

Method IsSdCard ?

Implement Method to test if an sdcard is exist.

always true in ios --โ‰ฅ no sdcard
always true in wp8 --> sdcard not use (in read only)

test in android
test in blackberry

Existing mbtiles-File not found

I just tested this plugin using the sample. While verifying process an existing local mbtiles file was not fount. The app always downloaded the file from web.

I could solve this by changing following lines in file map.js:

function verifyingMap(localFileName, remoteFile){

// leaving out the first lines... 

		mbTilesPlugin.init({type: type}, function(rinit) {
			mbTilesPlugin.getDirectoryWorking(function(r) {
				// alert("getDirectoryWorking Verify : " + r.directory_working);
				var absoluteLocalFileName = **"file://"+**r.directory_working + localFileName;

				// check to see if files already exists
			  var file = **window.resolveLocalFileSystemURL(absoluteLocalFileName, function** (fileEntry) {

// skipping rest of function

The seems to be a change in the cordova file plugin. Hope this will help for others...

Regarding Cordova MBTiles Plugin Map View

Hi.

I am working on a project where I need offline Map for Androids. I know MBTiles is a very good offline Map hence while searching internet I found your Cordova MBTiles Plugin and feels great interest to use. I am very new in Cordova JS. I am facing a problem in the App and I'll be glad if you please give me a clue to overcome it.

I made a Cordova App and added this MBTIles Plugin. Then I replaced the default "www" folder with the "plugins\com.makina.offline.mbtiles\sample\www" and rebuild the app. When I loaded the App in my Android Device I can see the "Click Me" Button but after Click on it nothing happens.

However, I checked the code where by Click on "Click Me" button a MBTiles file should download from "http://cg44.makina-corpus.net/tmp/POSOW-19.04.2012.mbtiles" and view it?

Please advise.

Thanks in advance.

Regards.

Working Directory

Maybe must be use the plugin file to find the right working directory in function of persistent , temporary, assets types of files provides by code JS.

This action will can synchronise the directory between the both plugin.

Support for Windows 8.1 and Windows 10

Hi,
has anyone already integrated this plugin into a Win10-App? Are there any hints what I have to do to get it working?
As far as I could figure out, the plugin.xml references Windows Phone 8? (This plugin works great for iOS and Android!)
I have changed WP8 to windows in the plugin.xml. But I think, this is not enough ๐Ÿ˜ƒ

When running the app, I get "Missing command error" - as I found this is thrown by Cordova if backend of a plugin is not well defined.
Any ideas what I have to change?

I am using Visual studio 2015 since I intend to create this app for Win8.1 and Win10. I have also installed the plugin cordova-sqlite-legacy, which provides an SQLite-DB for my data.

Best regards,
stihl-sicher

mbTilesPlugin.open Returns Null

We used the following command to open an off-line map in iOS and Android but since our last upgrade in cordova it fails (only in iOS) returning null.

App.mbTilesPlugin.open({name: 'NoCloud/map/map.mbtiles'},.......

To Info in WP8 of access Resources

Now we stock the data in context of application and not on sdcard, maybe in future we will need to stack the data on sdcard. The reason is due to the documentation of wp8 that it recommends to use sdcard only for MEDIA, PHOTO.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.