I'm trying to decode MVT data from the browser, to use it in the Google Maps API. In Python, I'm using the following package:
import mapbox_vector_tile
mapbox_vector_tile.decode(mvt_data) # this returns a nice json
But I have not found a way to do this on the client-side (Web browser). I have taken a look to mapbox-gl-js, but I have not seen any way to do it like in Python. Although importing all those things for only a decoder of MVT maybe it's a little bit overkill.
I want to use MVT because right now we have an image tile server but we want to change it to a vector tile server. We are using Google Maps API.
Do you know some package or way to accomplish this?
https://github.com/mapbox/awesome-vector-tiles is a great resource for tools and libraries related to vector tiles. There are several libraries in there for parsing and rendering vector tiles. https://github.com/mapbox/vector-tile-js is a good option if you just want to read the content of a tile.
Related
I am wondering if it's possible to use a shapefile with point features in arcmap as a web map?
I have seen examples, however most of them project the shapefile on top of a base layer map, for example, Google maps or ESRI maps. I am purely wanting to use the shapefile as a web map that supports zoom? Is this possible? If so, how would I go about achieving this?
The only method I can think of so far is to save the shapefile as a service to arcGIS for server...
Any guidance and help will be very helpful.
Thanks in advance.
You could start off by importing the shapefile into TileMill. Once you have styled the layer, you could export it as an MBTile and serve it with Mapbox.
I also found this description that you might find helpful.
http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html
Good Luck.
If there aren't too many points (more than a few hundred) then you probably want to generate GeoJSON from the shapefile and display the data that way.
You can convert your shapefile to geojson with the GDAL library.
ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp
If there are more than a few hundred points, then I'd use #andrewGeo's strategy.
The easier thing to do would be to share the shapefile from a server like ArcGIS Server or GeoServer. GeoServer tends to be easier to share something simple, especially if you use the Boundless Geo (http://boundlessgeo.com/). That comes with GeoExplorer which can directly consume a shapefile from GeoServer.
Depending on the API you're using to generate the basemap, you can hardcode x/y information into it or consume a KML/KMZ. These tend to be tedious and not great if you're doing more than just viewing static data.
If you choose the server option, beware about hosting and consuming your data on the same server. You may run into Cross Domain issues and life becomes a little more complex then. I believe GeoExplorer automatically bypassed any issues I had with Cross Domain, but most of the other JavaScript APIs were a little more troublesome.
With the release of QGIS 3.8 there is new feature to generate raster MBTiles layers. Once the layer you want to convert is setup, you can open up the Toolbox by either selecting the gear icon or by going into the processing tab on the menu bar and selecting toolbox. Then in the Processing Toolbox, drill-down into the Raster Tools section. Within this section, select the Generate XYZ tile (MBTiles) option. Then you can serve it into mapbox (currently GeoServer does support serving MBTiles as well by installing the MBTiles extension)
Here is a reference to this with a straight forward and well-illustrated example on how to use this new QGIS feature.
I want to make an app that allows users to download static images of maps and redistribute them in Anki flashcard decks. However, I'm having a tough time figuring out how to generate the map images without facing any licencing restrictions or running my own server. I want my app to be all client side JavaScript which rules out one of the solutions I've found so far. I've seen a way to use openlayers to export images from the canvas, however a proxy sever is required to convert the canvas to a dataURL so it can be saved.
The most promising option I've found so far is the MapQuest Open Static Maps API. However, I can't find much information about how open it really is. The OSM data is open, but I'm not sure about the images themselves, as they say copyright mapquest on them. Mapbox also has a static map API with licensing restrictions that are unclear to me.
I ended up using leaflet-image. leaflet-image can generate image dataURLs from leafletjs L.map objects using OSM tiles. It uses CORS to request the tiles and avoid tainting the canvas.
Thanks to #tyr for mentioning leaflet-image in his comment. The issues I mentioned in the comments have been resolved.
We developed a solution using TileMill to generate MBTiles files. We then developed a very simple PHP script, which opened the MBTiles (essentially a sqlite db) then saved the blobs for each image out to a file.
I am trying to see if it is possible to read a geotag from a photo using javascript. I would specifically like to do this for use in the google maps API. I know this is probably done on the server side most of the time, but I would like to know if it is possible.
Geotag data is stored as long/lat in the EXIF, and there is a client-side implementation of exif parser.
I have a database and web server filled with values for particular countries. I want to be able to display an interactive map that is color coded based on the values from my database upon querying it. (By interactive, I mean a simple zoom-in and move-around feature is all that is needed).
I have the shape files (.shp) of the world, and can easily get KML files as well. This all needs to be done in JavaScript/JQuery (using JQuery to grab the data from the database) and then apply a color code scheme to the shape file (fill in the country borders).
What would be a good JavaScript library to use for this? I have looked into OpenLayers but am unsure it can do what I need (perhaps I haven't dug deep enough).
It sounds like Leaflet.js would be another great option for you. Making choropleth maps in Leaflet is very easy and intercity (zooming) is standard.
You might try D3.js, which is a great framework in general, and has some basic Choropleth support, though I'm not sure how well it works natively with your existing files.
Check out:
http://mbostock.github.com/d3/ex/choropleth.html
I'm looking to use this chart generation library: http://www.jqchart.com/
Ideally, I would prefer to use a PHP charting library for the current project I'm working, but, by the looks of it, this is the only library I've found that can handle what I need to do (given a somewhat unconventional requirement for the charts).
The issue is that I need to get the generated graphs as images (at the moment each graph seems to be a combination of images) to the server so that I can generate some PDF documents, etc.
I'm thinking of attempting to create an image using JS, pushing this back to the server and then generating the PDF although this pretty nasty and will probably cause issues between different versions of the browser.
So now what I'm looking for is a solution that will allow me to generate the graphs and turn them into images on the backend.
Any ideas?
EDIT: For the requirement that led me to rule out a number of other charting libraries, see here: Complex charts in Google Charts
That really isn't all that relevant to the question of processing Javascript on the server, though.
You can render a javascript graph on the server using phantomjs. Here is an example.
Not sure what your requirements are, but I'd check out Google Chart Tools: http://code.google.com/apis/chart/. It's really simple to use. All the data is in the image URL get request, so you can generate charts using client-side JavaScript too.