MapXtreme for Java MAPJ Operations map

Source: Internet
Author: User

One, how to control the map display, such as Zoom out, zoom in. View the whole or part of the map. operates through the MAPJ class.

Generate Picture Dimensions
mymap.setdevicebounds (new doublerect (0, 0,,));
To set the horizontal span of the map, the unit has the distance unit of the map, if the current distance unit is kilometer, it means that the map crosses 1000-kilometer
mymap.setzoom (1000);
Set up the map center, position the map Center at a point on the mouse click
//create the screen coordinates of the object, X:event.getx on the screen (), Y:event.gety on the screen ()
doublepoint screenpoint = New Doublepoint (Event.getx (), event.gety ());
Converts screen coordinates to geographical coordinates
doublepoint worldpoint = Mymap.transformscreentonumeric (screenpoint);
Set up Map Center
mymap.setcenter (worldpoint);
Set the boundaries of the map, all the map operations within this boundary to do
//Method 1: The given boundary of the lower left and upper right corner, set the boundary.
doublerect bounds = new Doublerect ( -180,-90,180,90);
Mymap.setbounds (bounds);
Method 2: Given the center, width and height of the map, set the boundary.
doublerect bounds = new Doublerect (new Doublepoint (0,0), 360,180);
Mymap.setbounds (bounds);
The set map projection coordinates data is stored in the SERVER\MAPINFOW.PRJ file, containing hundreds of projections.
string csProj = new String ("\" Azimuthal equidistant (North Pole) \ ", 5, 7, 0,,");
Coordsys ts = coordsys.createfromprj (csProj);
Set map distance unit
linearunit distunit = linearunit.kilometer;
Mymap.setdistanceunits (Distunit);


Second, add layers

You can also add layers separately using the Layers.addlayer or Layers.addnamedlayer method. These methods place the layer in the
The end of the collection. The layer at the end of the collection is the underlying layer, which is first drawn. Layers.insertlayer or Insertnamedlayer
Used to control the position of the layer.
The map layers in the Layers collection are displayed in ascending order, starting with the 0 index. Featurelayer (0) is the top layer of the layer,
Featurelayer (1) is the layer below Featurelayer (0), and so on, the underlying layer is first drawn, and the top layer is finally drawn.
Data Provider definition Layer
To add a layer to the Layers collection, you must first define it. Each layer has an internal object that is responsible for data access, which is the provider of the data.
tabledeschelper-Description Data
dataproviderhelper-Define a data source
Dataproviderref-explains how to get data

Layers Layers = Mapj.getlayers ();
Tabledeschelper tabledeschelper = new Tabtabledeschelper (New File ("Query22.tab"). GetName ());
Dataproviderhelper dataproviderhelper = new Tabdataproviderhelper (datadir);//datadir:. tab
to store directory
dataproviderref dataproviderref = new Mapxtremedataproviderref (Dataproviderhelper, 
Mapxtremeurl);//mapxtremeurl:http://localhost:8090/mapxtreme/servlet/mapxtreme
Layers.add (DataProviderRef, Tabledeschelper, "Otherlayer");




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.