I am writing web application based on ArcGIS API for javascript. So far I managed to create empty map using this tutorial and write some code which visualizes some data.
The basemaps which ArcGIS offer are quite nice and I would like to use them, but they represent whole world and what I need is basemap of just a single country. What's the best/easiest way to do it? I tried using ArcGIS Online to edit basemap but the don't offer good options for cutting single country.
I found some links out there but they aren't solving my problem (or my knowledge is to small to understand them), for example https://developers.arcgis.com/javascript/latest/sample-code/basemap-custom/index.html
If you like the look and feel of the Esri basemaps, you don't want to make your own. That's certainly technically possible, but requires a greater command of ArcMap and publishing services -- and isn't what you're really looking for. And basemap tiles shouldn't be edited, even ones you publish yourself, since the difficulty of doing that well is just not worth the effort.
Instead, you can restrict the JavaScript map to prevent panning outside your area of interest. Whenever the user moves to an extent that exceeds allowed values, the code automatically resets the extent to the allowed limit, and they can't move outside it. (You can similarly restrict zoom levels so they won't even be able to zoom out further than the view of your area of interest.)
For code details, see existing answers on Restricting base map on specific extent in ArcGIS API for JavaScript 3? (GIS.StackExchange)
Related
I am triying to access microphone button at this page by using Processing. I got the source so I managed to launch my own pageIn order to do possible changes.
Is this possible? If it is not, is there any workaround to manipulate controls of this page?
This is going to be much more complicated than you're currently thinking.
If all you want to do is interact with the controls on that page, then you might look into the Robot class. This restricts you to deploying as a Java application (not as JavaScript), but it allows you to do things like move and click the mouse. That might be the way to go if you just want to interact with that page.
However, what you probably want is to use the underlying API being used by that page. If this is the case, you don't actually care about that webpage- that's just another client that's calling the API on the server. You need to create your own client that calls that same API.
To do that, you're going to need to write JavaScript that calls the API. Here is a guide on how to use the API.
It's hard to answer general "how do I do this" type questions. It's much easier to answer specific "I tried X, expected Y, but got Z instead" type questions. So I highly recommend reading the link I gave you (google is also your friend), trying to write some code, and posting an MCVE along with a specific question if you get stuck. Good luck.
I wonder is there any tool or standard methods to automatically testing programs that produce graphic outputs.
For example, a simple painting application is built allowing users to draw circles and rectangles in specific locations. The tests probably need to check whether the shapes are located in the exact place as specified.
My problem is: is there a standard way to automate the test procedure instead of letting tester manually check the outputs again and again?
There are several approaches, but the most important is, that the GUI part comes last.
The GUI is only responsible (or should be) for visualizing data. This implies that you have some underlying models and functionality, which is told to create a circle or rectangle at a certain position. You would usually test this first in order to make sure, your functionality does the right things and the underlying data is correct. Functionality and models can be fully covered by regular API tests.
Your particular question is to check, whether the visualization part is correct. You have IMHO two options for automation:
Use screenshots and diff the drawing canvas between a static expectation screenshot and the actual test result
Use tracing: You would take a screenshot from the canvas area and convert it to some vector image that allows you to check certain vectors for being at the right place
In general, GUI specifics such as the right color, exact placing are still human tasks. You can only try testing as much as you can using API tests and reduce the human part to a minimum.
I'm brand new to web technologies, and in researching a web app that I want to create I got a little bogged down. I want to be able to use a Google Map on my site, including the functionality that allows you to use layers and draw shapes and lines on top of it, but I'm confused at the difference between the Google Maps API and Google Maps Engine and which one would best suit me.
Is one of those a better option for me? There seems to be a lot of red tape on getting Maps Engine for a site, but I'm unclear on if Maps API has all the functionality I'd want.
Sorry for the beginner question, but I haven't found any sort of FAQ that's addressed this. I'd really appreciate any insight. Thanks!
So Google actually offers three different products.
Google Maps JavaScript API is intended for developers, and it lets you take Google's base maps and draw on them programmatically by writing your own JavaScript that calls the API.
Google Maps Engine is for creating your own base maps. You could use it to render shapes and lines on top of a map, but if that's all you want to do, it's probably overkill (and it's not free).
Google Maps Engine Lite is the new boy in town, and it's still beta as I type this, but it might fit your use case the best: you can draw by hand on top of Google's standard maps, import a variety of formats with geo data, and then share your results or embed them on your website, all without having to write a lick of JavaScript.
It all depends on how comfortable you are with coding. Google Maps API requires the application to be built in JavaScript.
As Google Maps Engine has now been shelved by Google I would suggest taking a look at MangoMap. It allows maps to be built using only an interface, you can built really powerful web ma applications without writing a single line of code.
Disclaimer: I'm the CEO of MangoMap ;-)
With Google Maps API, Google supplies a blank map and you add points, line, polygons, etc. to the map via JavaScript. This is great until you start having to add thousands of map objects.
With Google Maps Engine, (now deprecated), you upload, store, and process the geometry data on Google's servers for optimal rendering. You can turn a large group of points and lines into image files with transparent backgrounds which can display quickly on a map.
I'm a "do it yourself" kind of guy, but I want to make sure I'm not going to do myself in by trying to bite off more than I can chew.
I am writing a browser-based mapping application that needs to have the option to run standalone (no internet connection) on the end-user's machine. That is, the application is some kind of server that will, in many cases, get installed on the end user's machine and the browser will point to some localhost URL to access it.
I will be using MapLayers on the client side, and the server side will have a bunch of custom logic specific to the application, such as handling click events on the map in certain custom ways, creating various custom objects on the map at certain times, and so on.
For the "business logic" part of the server, I'm happy using paste/webob with python. It's a simple infrastructure that lets me put all this custom logic in easily.
I had been thinking that the client would communicate with two servers: this paste/webob business logic server, and a server just for serving WMS and WFS map elements. So I was looking at MapServer and GeoServer to handle the map parts and ... I'm not happy.
I'm not happy because I don't want to have to install and worry about a "beast" on the client machines. For MapServer, I don't really want to install a full-blown web server like Apache, and have to deal with CGI and PHP and MapScript. For GeoServer, there's (potentially) installing Java, and dealing with various complexities of the GeoServer setup and administration.
Part of this is simply a learning curve issue. If I can avoid it, I'm not especially interested in learning the intricacies of either MapServer or GeoServer. I installed GeoServer, pointed it to some of my data, and was able to use the MapLayers preview built into GeoServer's nice web admin to view my data. But when I tried to serve the data for real using my own MapLayers web page pointed at GeoServer, I crashed GeoServer. That I could crash the server just be sending some presumably malformed requests from the client was quite surprising to me. And I could dig into the GeoServer logs to try to figure out what I did wrong, but ... I don't really want to spend a lot of time on that.
So, I am considering implementing parts of the WMS and WFS interface myself just using the paste/webob server I already have. It may in fact be that I only need the WMS, since I might handle vector objects through a simple custom protocol that I make to pass data to the client, which can then create and manipulate the objects directly using OpenLayers.
I've looked at the specs and example messages for WMS (and a bit less at WFS). It seems not so difficult just to implement this protocol myself, especially because I have full control of the client in this case -- it's not like I need to be able to act as a generic WMS or WFS server; I just have to make my own OpenLayers client happy.
The two main abilities that I need the WMS server to have are:
Serve tiles from a store of prerendered tiles that I've created ahead of time (I'll prerender the tiles using OpenStreetMap data and mapnik as the redering engine; and I'll store and access them using the normal Google Maps style tile naming scheme that OpenLayers expects)
Have the ability to server modified versions of these tiles where certain data that I store locally is drawn on top of the tiles. For instance, I might have, say, 10000 points on one "layer" and 10000 polygons on another layer, and when the user activates these layers I will serve my same base tiles, but as I'm serving these tiles I'll render these additional features on top of them, and probably I'll implement a simple caching scheme to keep these over-rendered tiles around for some amount of time.
So my question is: Even though I know there are existing tools that do these things (MapServer, GeoServer, TileCache, and others), I'm actually feeling like it's less work for me to just to respond to some simple WMS messages, and do this additional over-drawing on my tiles myself in python, making sure everything is projected correctly, etc. I don't need to draw fancy wide streets or anything for these over-layers, just simple lines, icons, and perhaps labels. It sure sounds nice and simple to have a python-only solution.
I figure if I ever need to expand into supporting more of the WMS/WFS protocol, or doing fancier overdrawing, I can just insert MapServer/GeoServer at that time.
Are there pitfalls here I'm not considering?
Mapserver is very easy to setup and learn. Implementing any kind of rendering by yourself is going to require much more effort, and you will probably find a lots of unexpected traps.
mapserver cgi should be enough for your needs. If you require some very specific tweak, then mapscript can be useful.
I think it could be interesting if you could make a pure JavaScript application, and save yourself from installing a web server (and a map server). If you just needed browsing a tile mosaic, may be you could do it just with JavaScript (generate an html table with a cell for each tile). You can render points or polygons, with JavaScript, using a canvas and doing some basic coordinate conversion to translate geographic points to pixels. Openlayers have this functionality, I think.
EDIT: I just checked and with Openlayers you can browse local tiles, and you can render kml and some other vect data. So, I think you should give Openlayers a try.
No need to have a wms/wfs. What you need is a tile implementation. Basically you should have some sort of central service, or desktop service that generates the tiles. Once these tiles are generated, you can simply transform them to your "no-real-webserver-architecture" filesystem. You can create a directory structure that conforms to /{x}/{y}/{z}.png and call it from javascript.
An example of how openstreetmap does this can be found here: http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example
You may like featureserver: http://featureserver.org/.
It has its own WFS. I am using it right now.
I'd like to add a map of countries to my website where the user can choose a specific country by clicking on it. http://code.google.com/apis/chart/docs/gallery/map_charts.html has the looks i want, but it's not possible to underlay the countries with links, afaik(Besides lacking pan/zoom, nice to have). The interactive map(Geo Map) allows more options but it's based on flash which i'd like to avoid(Not sure if links would be possible anyway).
I've played with shapefiles/polylines and google-maps but thats too complex(Lots of data for the polylines, far too much for the simple functionality i need).
Do you know of alternatives which are similarly easy to implement as the google-api-options?
Thx
Christian
I would, if I may, suggest to check out Highmaps, from the people behind Highcharts (myself included). It's 100% Javascript based, and designed to get you up and going with very little effort. You can easily implement your own click-based events.
Highmaps is free for non-commercial use, works great with mobile browsers (full touch support) and old IE down to IE6. It also has support for advanced dynamic features like drilldown and rich tooltips, and is very customizable.
We supply a map collection with over 350 maps, to get you started quickly. The maps are optimized for size to keep things lightweight.