Why JxMaps

Maps

Google Maps API in Java

Provides Java wrappers for the majority of Google Maps JavaScript API classes. You don’t need to learn or use JavaScript to work with maps.

Creative

More Time to Be Creative

Integrate Google Maps into JavaFX or Java Swing application in less than an hour. Check out the code examples.

See Code Examples

Support

Professional Support

All support requests are handled directly by our development team with 15 years of experience in Java integration.

Using JxMaps

Here are just a few examples of applications using JxMaps

Tracking Things

Display geoposition of the GPS-enabled assets from drones and aircraft to pet trackers.

Logistics and Dispatch Systems

Track vehicles and build optimal routes and travel time estimates.

Kiosks with Interactive Maps

Show maps with customized markers, provide tourists with directions and info on nearby hotels, restaurants or banks.

Geodata Visualization

Map geotagged entries and graphically display spatial distribution data.

Real Estate Mapping

Display properties location and map important information about each asset.

Contact Location

Show location of the contact based on the address in a contact management system or CRM.

Features

  • Maps Integration Map Integration
  • Geocoding Geocoder
  • Directions Directions
  • Place Search Places Search
  • Drawing on the Map Polygons
  • Street view Street View
  • Traffic Layer
  • Maps Integration Map Integration JavaFX
More examples on GitHub
Run Demo

Runs on Windows, macOS, and Linux with JRE 1.6+, 32/64-bit

Integrating a Google Map into your Java Swing application is easy.

Map Integration MapExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */
      
package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.swing.MapView;
import javax.swing.*;
import java.awt.*;

/**
* This example demonstrates how to create a MapView instance,
* display it in JFrame and open a simple map.
*
* @author Vitaly Eremenko
*/
  
public class MapExample extends MapView {
    public MapExample() {

        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and     
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    // Getting the associated map object
                    final Map map = getMap();
                    // Creating a map options object
                    MapOptions options = new MapOptions(map);
                    // Creating a map type control options object
                    MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
                    // Changing position of the map type control
                    controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting map type control options
                    options.setMapTypeControlOptions(controlOptions);
                    // Setting map options
                    map.setOptions(options);
                    // Setting the map center
                    map.setCenter(new LatLng(map, 35.91466, 10.312499));
                    // Setting initial zoom value
                    map.setZoom(2.0);
                }
            }
        });
    }

    public static void main(String[] args) {
        MapExample sample = new MapExample();

        JFrame frame = new JFrame("Map Integration");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(sample, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Get geographic coordinates out of addresses and vice versa. Mark the position on the map.

Geocoder GeocoderExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */

package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.GeocoderCallback;
import com.teamdev.jxmaps.GeocoderRequest;
import com.teamdev.jxmaps.GeocoderResult;
import com.teamdev.jxmaps.GeocoderStatus;
import com.teamdev.jxmaps.InfoWindow;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.Marker;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicTextFieldUI;
import java.awt.*;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * This example demonstrates how to geocode coordinates by an address and vice versa.
 *
 * @author Vitaly Eremenko
 * @author Sergei Piletsky
 */
    
public class GeocoderExample extends MapView {

    private static final String INITIAL_LOCATION = "Beijing";

    private OptionsWindow optionsWindow;

    public GeocoderExample() {
        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and     
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Getting the associated map object
                final Map map = getMap();
                // Setting initial zoom value
                map.setZoom(7.0);
                // Creating a map options object
                MapOptions options = new MapOptions(map);
                // Creating a map type control options object
                MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
                // Changing position of the map type control
                controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                // Setting map type control options
                options.setMapTypeControlOptions(controlOptions);
                // Setting map options
                map.setOptions(options);

                performGeocode(INITIAL_LOCATION);
            }
        });
    }

    @Override
    public void addNotify() {
        super.addNotify();

        optionsWindow = new OptionsWindow(this, new Dimension(350, 40)) {
            @Override
            public void initContent(JWindow contentWindow) {
                JPanel content = new JPanel(new GridBagLayout());
                content.setBackground(Color.white);

                Font robotoPlain13 = new Font("Roboto", 0, 13);
                final JTextField searchField = new JTextField();
                searchField.setText(INITIAL_LOCATION);
                searchField.setToolTipText("Enter address or coordinates...");
                searchField.setBorder(BorderFactory.createEmptyBorder());
                searchField.setFont(robotoPlain13);
                searchField.setForeground(new Color(0x21, 0x21, 0x21));
                searchField.setUI(new SearchFieldUI(searchField));

                final JButton searchButton = new JButton();
                searchButton.setIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search.png")));
                searchButton.setRolloverIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search_hover.png")));     
                searchButton.setBorder(BorderFactory.createEmptyBorder());
                searchButton.setUI(new BasicButtonUI());
                searchButton.setOpaque(false);
                ActionListener searchActionListener = new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        performGeocode(searchField.getText());
                    }
                };
                searchButton.addActionListener(searchActionListener);
                searchField.addActionListener(searchActionListener);

                content.add(searchField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                        GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 0), 0, 0));
                content.add(searchButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
                        GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(11, 0, 11, 11), 0, 0));

                contentWindow.getContentPane().add(content);
            }

            @Override
            protected void updatePosition() {
                if (parentFrame.isVisible()) {
                    Point newLocation = parentFrame.getContentPane().getLocationOnScreen();
                    newLocation.translate(56, 11);
                    contentWindow.setLocation(newLocation);
                    contentWindow.setSize(340, 40);
                }
            }
        };
    }

    class SearchFieldUI extends BasicTextFieldUI {
        private final JTextField textField;

        public SearchFieldUI(JTextField textField) {
            this.textField = textField;
        }

        @Override
        protected void paintBackground(Graphics g) {
            super.paintBackground(g);
            String toolTipText = textField.getToolTipText();
            String text = textField.getText();
            if (toolTipText != null && text.isEmpty()) {
                paintPlaceholderText(g, textField);
            }
        }

        protected void paintPlaceholderText(Graphics g, JComponent c) {
            g.setColor(new Color(0x75, 0x75, 0x75));
            g.setFont(c.getFont());
            String text = textField.getToolTipText();
            if (g instanceof Graphics2D) {
                Graphics2D graphics2D = (Graphics2D) g;
                graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            }
            g.drawString(text, 0, 14);
        }
    }

    @Override
    public void removeNotify() {
        super.removeNotify();
        optionsWindow.dispose();
    }

    private void performGeocode(String text) {
        // Getting the associated map object
        final Map map = getMap();
        // Creating a geocode request
        GeocoderRequest request = new GeocoderRequest(map);
        // Setting address to the geocode request
        request.setAddress(text);

        // Geocoding position by the entered address
        getServices().getGeocoder().geocode(request, new GeocoderCallback(map) {
            @Override
            public void onComplete(GeocoderResult[] results, GeocoderStatus status) {
                // Checking operation status
                if ((status == GeocoderStatus.OK) && (results.length > 0)) {
                    // Getting the first result
                    GeocoderResult result = results[0];
                    // Getting a location of the result
                    LatLng location = result.getGeometry().getLocation();
                    // Setting the map center to result location
                    map.setCenter(location);
                    // Creating a marker object
                    Marker marker = new Marker(map);
                    // Setting position of the marker to the result location
                    marker.setPosition(location);
                    // Creating an information window
                    InfoWindow infoWindow = new InfoWindow(map);
                    // Putting the address and location to the content of the information window
                    infoWindow.setContent("<b>" + result.getFormattedAddress() + "</b><br>" + location.toString());
                    // Moving the information window to the result location
                    infoWindow.setPosition(location);
                    // Showing of the information window
                    infoWindow.open(map, marker);
                }
            }
        });
    }


    public static void main(String[] args) {
        final GeocoderExample mapView = new GeocoderExample();

        JFrame frame = new JFrame("Geocoder");

        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(mapView, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Build routes and get directions between multiple positions on a map for transit, driving, cycling or walking modes of transportation.

Directions DirectionsExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */
    
package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.DirectionsRequest;
import com.teamdev.jxmaps.DirectionsResult;
import com.teamdev.jxmaps.DirectionsRouteCallback;
import com.teamdev.jxmaps.DirectionsStatus;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.TravelMode;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import javax.swing.border.AbstractBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * This example demonstrates how to calculate a route between two locations.
 *
 * @author Vitaly Eremenko
 */
    
public class DirectionsExample extends MapView implements ControlPanel {

    private static final Color FOREGROUND_COLOR = new Color(0xBB, 0xDE, 0xFB);

    private JTextField fromField;
    private JTextField toField;

    private JPanel controlPanel;

    public DirectionsExample() {
        controlPanel = new JPanel();

        fromField = new JTextField("Chicago, il");
        toField = new JTextField("Winona, az");

        configureControlPanel();

        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    // Getting the associated map object
                    final Map map = getMap();
                    // Setting the map center
                    map.setCenter(new LatLng(map, 41.85, -87.65));
                    // Setting initial zoom value
                    map.setZoom(7.0);
                    // Creating a map options object
                    MapOptions options = new MapOptions(map);
                    // Creating a map type control options object
                    MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
                    // Changing position of the map type control
                    controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting map type control options
                    options.setMapTypeControlOptions(controlOptions);
                    // Setting map options
                    map.setOptions(options);

                    calculateDirection();
                }
            }
        });
    }

    @Override
    public JComponent getControlPanel() {
        return controlPanel;
    }

    @Override
    public void configureControlPanel() {
        controlPanel.setBackground(Color.white);
        controlPanel.setLayout(new BorderLayout());

        JPanel demoControlPanel = new JPanel(new GridBagLayout());
        demoControlPanel.setBackground(new Color(61, 130, 248));

        Font robotoPlain13 = new Font("Roboto", 0, 13);
        fromField.setForeground(FOREGROUND_COLOR);
        toField.setForeground(FOREGROUND_COLOR);

        fromField.setFont(robotoPlain13);
        toField.setFont(robotoPlain13);

        fromField.setOpaque(false);
        toField.setOpaque(false);

        fromField.setBorder(new UnderscoreBorder());
        toField.setBorder(new UnderscoreBorder());

        ActionListener listener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                calculateDirection();
            }
        };
        fromField.addActionListener(listener);
        toField.addActionListener(listener);

        JLabel fromIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/from.png")));
        JLabel dotsIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/dots.png")));
        JLabel toIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/to.png")));
        JLabel changeIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/change.png")));
        changeIcon.setToolTipText("Reverse starting point and destination");
        changeIcon.setCursor(new Cursor(Cursor.HAND_CURSOR));
        changeIcon.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                String from = fromField.getText();
                String to = toField.getText();
                fromField.setText(to);
                toField.setText(from);
                calculateDirection();
            }
        });

        demoControlPanel.add(fromIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(22, 30, 0, 0), 0, 0));
        demoControlPanel.add(dotsIcon, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 33, 0, 0), 0, 0));
        demoControlPanel.add(toIcon, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(6, 30, 25, 0), 0, 0));

        demoControlPanel.add(fromField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(19, 22, 0, 0), 0, 0));
        demoControlPanel.add(toField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(3, 22, 0, 0), 0, 0));

        demoControlPanel.add(changeIcon, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 22, 0, 22), 0, 0));

        controlPanel.add(demoControlPanel, BorderLayout.NORTH);
    }

    @Override
    public int getPreferredHeight() {
        return 169;
    }

    class UnderscoreBorder extends AbstractBorder {
        @Override
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
            g.setColor(FOREGROUND_COLOR);
            g.drawLine(0, height - 1, width, height - 1);
        }

        @Override
        public Insets getBorderInsets(Component c) {
            return new Insets(0, 0, 5, 0);
        }

        @Override
        public Insets getBorderInsets(Component c, Insets insets) {
            insets.bottom = 5;
            return insets;
        }
    }

    private void calculateDirection() {
        // Getting the associated map object
        final Map map = getMap();
        // Creating a directions request
        DirectionsRequest request = new DirectionsRequest(map);
        // Setting of the origin location to the request
        request.setOriginString(fromField.getText());
        // Setting of the destination location to the request
        request.setDestinationString(toField.getText());
        // Setting of the travel mode
        request.setTravelMode(TravelMode.DRIVING);
        // Calculating the route between locations
        getServices().getDirectionService().route(request, new DirectionsRouteCallback(map) {
            @Override
            public void onRoute(DirectionsResult result, DirectionsStatus status) {
                // Checking of the operation status
                if (status == DirectionsStatus.OK) {
                    // Drawing the calculated route on the map
                    map.getDirectionsRenderer().setDirections(result);
                } else {
                    JOptionPane.showMessageDialog(DirectionsExample.this, "Error. Route cannot be calculated.\nPlease correct input data.");     
                }
            }
        });
    }

    private static void loadAndRegisterCustomFonts() {
        try {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Bold.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Medium.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Regular.ttf")));     
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Thin.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Light.ttf")));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        loadAndRegisterCustomFonts();

        JFrame frame = new JFrame("Directions");
        final DirectionsExample sample = new DirectionsExample();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(sample, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        OptionsWindow optionsWindow = new OptionsWindow(sample, new Dimension(300, 100)) {
            @Override
            public void initContent(JWindow contentWindow) {
                contentWindow.add(sample.controlPanel);
            }
        };
    }
}

Show places with detailed description based on a specified location or a search string.

Places Search PlacesSearchExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */

package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.GeocoderCallback;
import com.teamdev.jxmaps.GeocoderRequest;
import com.teamdev.jxmaps.GeocoderResult;
import com.teamdev.jxmaps.GeocoderStatus;
import com.teamdev.jxmaps.Icon;
import com.teamdev.jxmaps.InfoWindow;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapEvent;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.MapViewOptions;
import com.teamdev.jxmaps.Marker;
import com.teamdev.jxmaps.PhotoOptions;
import com.teamdev.jxmaps.PlaceDetailsCallback;
import com.teamdev.jxmaps.PlaceDetailsRequest;
import com.teamdev.jxmaps.PlaceNearbySearchCallback;
import com.teamdev.jxmaps.PlacePhoto;
import com.teamdev.jxmaps.PlaceResult;
import com.teamdev.jxmaps.PlaceSearchPagination;
import com.teamdev.jxmaps.PlaceSearchRequest;
import com.teamdev.jxmaps.PlacesService;
import com.teamdev.jxmaps.PlacesServiceStatus;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.xml.bind.DatatypeConverter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;


/**
 * This example demonstrates how to find places on the map.
 * Also it demonstrates how to get details about selected place.
 *
 * @author Vitaly Eremenko
 * @author Sergei Piletsky
 */
      
public class PlacesSearchExample extends MapView implements EditableTextControlPanel  {
    static final MapViewOptions mapOptions;

    static {
        // initializing a map view options
        mapOptions = new MapViewOptions();
        // enabling usage of places library
        mapOptions.importPlaces();
    }

    private final boolean standalone;

    private static String convertImageStreamToString(InputStream is) {
        String result;
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            int nRead;
            byte[] data = new byte[10240];
            while ((nRead = is.read(data, 0, data.length)) != -1) {
                buffer.write(data, 0, nRead);
            }
            buffer.flush();
            result = "data:image/png;base64," + DatatypeConverter.printBase64Binary(buffer.toByteArray());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }

    private static String getBase64ImageString(String imageName) {
        InputStream is = PlacesSearchExample.class.getResourceAsStream("res/" + imageName);
        return convertImageStreamToString(is);
    }

    static final String restarantIcon = getBase64ImageString("restaurants_for_map.png");
    static final String barIcon = getBase64ImageString("bars_and_pubs_for_map.png");
    static final String hotelIcon = getBase64ImageString("hotels_for_map.png");
    static final String restarantIconHover = getBase64ImageString("restaurants_for_map.png");
    static final String barIconHover = getBase64ImageString("bars_and_pubs_for_map.png");
    static final String hotelIconHover = getBase64ImageString("hotels_for_map.png");

    private OptionsWindow optionsWindow;
    private JTextField addressEdit;
    private JList placesList;
    private ExtendedMarker[] markers;
    private Marker mainMarker;
    private JPanel controlPanel;

    static class ExtendedMarker extends Marker {

        private Icon hoverIcon;
        private Icon normalIcon;
        private final Map map;
        private final PlacesService placesService;

        public void setPlaceId(String placeId) {
            this.placeId = placeId;
        }

        private String placeId;

        public ExtendedMarker(Map map, PlacesService placesService) {
            super(map);
            this.map = map;
            this.placesService = placesService;

            addEventListener("mouseover", new MapEvent() {
                @Override
                public void onEvent() {
                    if (hoverIcon != null) {
                        setIcon(hoverIcon);
                    }
                }
            });
            addEventListener("mouseout", new MapEvent() {
                @Override
                public void onEvent() {
                    if (normalIcon != null) {
                        setIcon(normalIcon);
                    }
                }
            });
            addEventListener("click", new MapEvent() {
                @Override
                public void onEvent() {
                    showInfoWindow();
                }
            });
        }

        /**
         * Showing info window for certain place
         */
      
        private void showInfoWindow() {
            // Checking if placeId value is set
            if (placeId != null) {
                // Creating place details request
                PlaceDetailsRequest request = new PlaceDetailsRequest(map);
                // Setting placeId to search request
                request.setPlaceId(placeId);
                // Requesting details for the place by provided placeId
                placesService.getDetails(request, new PlaceDetailsCallback(map) {
                        @Override
                        public void onComplete (PlaceResult result, PlacesServiceStatus status){
                            // Checking operation status
                            if (status == PlacesServiceStatus.OK) {
                                // Creating a info window
                                InfoWindow window = new InfoWindow(map);
                                // Getting details from result and setting it as info window context
                                window.setContent(getContentByResult(result));
                                // Setting info window position
                                window.setPosition(getPosition());
                                // Showing information about place
                                window.open(map, this);
                            }
                        }
                    }
                );
            }
        }

        private String getContentByResult(PlaceResult result) {

            String textContent = "<p><b>" + result.getName() + "</b></p>";
            textContent += "<p>" + result.getFormattedAddress() + "</p>";

            // Creating a photo options object
            PhotoOptions option = new PhotoOptions(map);
            // Setting maximum photo height
            option.setMaxHeight(64);
            // Setting maximum photo width
            option.setMaxWidth(64);

            // Getting photos from result
            PlacePhoto[] photos = result.getPhotos();

            if ((photos != null) && (photos.length > 0)) {
                PlacePhoto photo = photos[0];
                String imageContent = "<table cellspacing=\"0\" cellpadding=\"5\"><tr><td><img src=\"" + photo.getUrl(option);
                imageContent += "\" /></td><td>";
                textContent = imageContent + textContent;
                textContent += "</td></tr></table>";
            }

            return textContent;
        }

        public void setIcons(String normalIcon, String hoverIcon) {
            this.normalIcon = new Icon(map);
            this.normalIcon.setUrl(normalIcon);;

            this.hoverIcon = new Icon(map);
            this.hoverIcon.setUrl(hoverIcon);

            setIcon(this.normalIcon);
        }
    }

    public PlacesSearchExample() {
        this(false);
    }

    public PlacesSearchExample(boolean standalone) {
        super(mapOptions);
        this.standalone = standalone;

        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    init();
                }
            }
        });

        controlPanel = new JPanel();

        addressEdit = new JTextField("London, Baker str., 221b");
        addressEdit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                geocodePlace(addressEdit.getText());
            }
        });

        placesList = new JList<String>(new String[]{"Restaurants", "Hotels", "Bars and pubs"});
        placesList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                findPlaces();
            }
        });

        configureControlPanel();
    }

    @Override
    public JComponent getControlPanel() {
        return controlPanel;
    }

    @Override
    public int getPreferredHeight() {
        return 233;
    }

    class PlaceOption {
        final ImageIcon icon;
        final String name;

        public PlaceOption(ImageIcon icon, String name) {
            this.icon = icon;
            this.name = name;
        }

        public ImageIcon getIcon() {
            return icon;
        }

        public String getName() {
            return name;
        }
    }

    class PlaceOptionsRenderer extends JPanel implements ListCellRenderer {
        private final Color SELECTION_BACKGROUND = new Color(0xFA, 0xFA, 0xFA);

        private final JLabel imageLabel;
        private final JLabel text;

        public PlaceOptionsRenderer() {
            setLayout(new GridBagLayout());

            imageLabel = new JLabel();
            imageLabel.setPreferredSize(new Dimension(18, 18));
            text = new JLabel();

            Font robotoPlain13 = new Font("Roboto", 0, 13);
            text.setFont(robotoPlain13);
            text.setForeground(new Color(0x21, 0x21, 0x21));

            add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0
                    , GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 22, 20, 22), 0, 0));

            add(text, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
                    , GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(20, 8, 20, 22), 0, 0));
        }
        public Component getListCellRendererComponent(JList list,
                                                      Object value,
                                                      int index,
                                                      boolean isSelected,
                                                      boolean cellHasFocus) {
            if (isSelected) {
                setBackground(SELECTION_BACKGROUND);
            } else {
                setBackground(list.getBackground());
            }
            PlaceOption placeOption = (PlaceOption) value;
            imageLabel.setIcon(placeOption.getIcon());
            text.setText(placeOption.getName());
            return this;
        }
    }

    @Override
    public void configureControlPanel() {
        controlPanel.removeAll();
        controlPanel.setBackground(Color.white);
        controlPanel.setLayout(new BorderLayout());

        placesList = new JList<PlaceOption>(new PlaceOption[]{
                new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/restaurants.png")), "Restaurants"),
                new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/hotels.png")), "Hotels"),
                new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/bars_and_pubs.png")), "Bars and pubs"),
        });

        placesList.setCellRenderer(new PlaceOptionsRenderer());
        placesList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                findPlaces();
            }
        });
        placesList.setOpaque(false);
        placesList.setCursor(new Cursor(Cursor.HAND_CURSOR));

        if (standalone) {
            controlPanel.add(addressEdit, BorderLayout.NORTH);
        }

        controlPanel.add(placesList, BorderLayout.CENTER);
    }

    @Override
    public void onTextEntered(String value) {
        geocodePlace(value);
    }

    @Override
    public String getInitialText() {
        return addressEdit.getText();
    }

    private void findPlaces() {

        if (placesList.getSelectedIndex() < 0)
            return;

        // Getting the associated map object
        final Map map = getMap();
        // Creating places search request
        final PlaceSearchRequest request = new PlaceSearchRequest(map);
        // Setting start point for places search
        request.setLocation(map.getCenter());
        // Setting radius for places search
        request.setRadius(500.0);

        final int imageType = placesList.getSelectedIndex();

        final String iconUrl[] = new String[2];

        switch (imageType) {
            case 0:
                iconUrl[0] = restarantIcon;
                iconUrl[1] = restarantIconHover;

                request.setTypes(new String[]{"restaurant"});
                break;
            case 1:
                iconUrl[0] = hotelIcon;
                iconUrl[1] = hotelIconHover;

                request.setTypes(new String[]{"hotels"});
                break;
            case 2:
                iconUrl[0] = barIcon;
                iconUrl[1] = barIconHover;

                request.setTypes(new String[]{"bar"});
                break;
        }

        // Searching places near specified location
        getServices().getPlacesService().nearbySearch(request, new PlaceNearbySearchCallback(map) {
            @Override
            public void onComplete(PlaceResult[] results, PlacesServiceStatus status, PlaceSearchPagination pagination) {
                // Checking operation status
                if (status == PlacesServiceStatus.OK) {
                    clearMarkers();

                    // Creating markers for each place
                    markers = new ExtendedMarker[results.length];
                    for (int i=0; i< results.length; ++i) {
                        PlaceResult result = results[i];
                        // Creating a marker for place found
                        markers[i] = new ExtendedMarker(map, getServices().getPlacesService());
                        // Associating the marker with placeId (will be used on place details search)
                        markers[i].setPlaceId(result.getPlaceId());
                        // Moving the marker to place location
                        LatLng location = result.getGeometry() != null ? result.getGeometry().getLocation() : null;
                        // Setting icons for the marker
                        markers[i].setIcons(iconUrl[0],iconUrl[1]);
                        if (location != null)
                            // Setting the marker position
                            markers[i].setPosition(location);
                    }
                }
            }
        });

    }

    private void geocodePlace(String address) {
        if (mainMarker != null)
            mainMarker.setVisible(false);
        mainMarker = null;
        clearMarkers();

        // Getting the associated map object
        final Map map = getMap();

        // Creating geocoder request
        GeocoderRequest request = new GeocoderRequest(map);
        // Set address for request
        request.setAddress(address);
        // Geocoding a position by address
        getServices().getGeocoder().geocode(request, new GeocoderCallback(map) {
            @Override
            public void onComplete(GeocoderResult[] results, GeocoderStatus status) {
                // Checking operation status
                if ((status == GeocoderStatus.OK) && (results.length > 0)) {
                    // Getting first result
                    GeocoderResult result = results[0];
                    // Getting location (coords)
                    LatLng location = result.getGeometry().getLocation();
                    // Centering map to result location
                    map.setCenter(location);
                    // Initializing main marker
                    mainMarker = new Marker(map);
                    // Moving marker to result location
                    mainMarker.setPosition(location);
                    // Showing marker on map
                    mainMarker.setVisible(true);

                    findPlaces();
                }
            }
        });
    }

    private void clearMarkers() {
        if (markers == null)
            return;
        for (Marker marker : markers) {
            marker.setVisible(false);
        }
        markers = null;
    }

    private void init() {
        // Getting the associated map object
        final Map map = getMap();
        // Creating a map options object
        MapOptions options = new MapOptions(map);
        // Creating a map type control options object
        MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
        // Changing position of the map type control
        controlOptions.setPosition(ControlPosition.TOP_RIGHT);
        // Setting map type control options
        options.setMapTypeControlOptions(controlOptions);
        // Setting map options
        map.setOptions(options);
        // Setting initial zoom value
        map.setZoom(15.0);

        geocodePlace(addressEdit.getText());
    }

    private static void loadAndRegisterCustomFonts() {
        try {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Bold.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Medium.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Regular.ttf")));     
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Thin.ttf")));
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Light.ttf")));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        loadAndRegisterCustomFonts();

        final PlacesSearchExample sample = new PlacesSearchExample(true);

        JFrame frame = new JFrame("Places Search");

        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(sample, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        new OptionsWindow(sample, new Dimension(350, 200)) {
            @Override
            public void initContent(JWindow contentWindow) {
                contentWindow.add(sample.controlPanel);
            }
        };
    }
}

Display custom shapes on the map.

Polygons PolygonExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */
    
package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.Polygon;
import com.teamdev.jxmaps.PolygonOptions;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import java.awt.*;

/**
 * This example demonstrates how to draw polygons on the map.
 *
 * @author Vitaly Eremenko
 */
    
public class PolygonExample extends MapView {
    public PolygonExample() {
        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and     
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    // Getting the associated map object
                    final Map map = getMap();
                    // Creating a map options object
                    MapOptions mapOptions = new MapOptions(map);
                    // Creating a map type control options object
                    MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
                    // Changing position of the map type control
                    controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting map type control options
                    mapOptions.setMapTypeControlOptions(controlOptions);
                    // Setting map options
                    map.setOptions(mapOptions);
                    // Setting the map center
                    map.setCenter(new LatLng(map, 24.886, -70.268));
                    // Setting initial zoom value
                    map.setZoom(5.0);
                    // Creating a path (array of coordinates) that represents a polygon
                    LatLng[] path = {new LatLng(map, 25.774, -80.190),
                            new LatLng(map, 18.466, -66.118),
                            new LatLng(map, 32.321, -64.757),
                            new LatLng(map, 25.774, -80.190)};
                    // Creating a new polygon object
                    Polygon polygon = new Polygon(map);
                    // Initializing the polygon with the created path
                    polygon.setPath(path);
                    // Creating a polyline options object
                    PolygonOptions options = new PolygonOptions(map);
                    // Setting fill color value
                    options.setFillColor("#FF0000");
                    // Setting fill opacity value
                    options.setFillOpacity(0.35);
                    // Setting stroke color value
                    options.setStrokeColor("#FF0000");
                    // Setting stroke opacity value
                    options.setStrokeOpacity(0.8);
                    // Setting stroke weight value
                    options.setStrokeWeight(2.0);
                    // Applying options to the polygon
                    polygon.setOptions(options);
                }
            }
        });
    }

    public static void main(String[] args) {
        final PolygonExample sample = new PolygonExample();

        JFrame frame = new JFrame("Polygons");

        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(sample, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

}

Display Street View panoramas directly in the map.

Street View StreetViewExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */

package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.StreetViewAddressControlOptions;
import com.teamdev.jxmaps.StreetViewPanoramaOptions;
import com.teamdev.jxmaps.StreetViewPov;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import java.awt.*;

/**
 * This example demonstrates how to display street view panorama with a map.
 *
 * @author Vitaly Eremenko
 */
    
public class StreetViewExample extends MapView {
    public StreetViewExample() {
        super(true);

        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and     
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    // Getting the associated map object
                    Map map = getMap();
                    // Creating a map options object
                    MapOptions mapOptions = new MapOptions(map);
                    // Creating a map type control options object
                    MapTypeControlOptions controlOptions = new MapTypeControlOptions(map);
                    // Changing position of the map type control
                    controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting map type control options
                    mapOptions.setMapTypeControlOptions(controlOptions);
                    // Setting map options
                    map.setOptions(mapOptions);
                    // Setting the map center
                    map.setCenter(new LatLng(map, 51.500871, -0.1222632));
                    // Setting initial zoom value
                    map.setZoom(13.0);
                    // Creating a street view panorama options object
                    StreetViewPanoramaOptions options = new StreetViewPanoramaOptions(map);
                    // Creating a street view address control options object
                    StreetViewAddressControlOptions svControlOptions = new StreetViewAddressControlOptions(map);
                    // Changing position of the address control on the panorama
                    svControlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting address control options
                    options.setAddressControlOptions(svControlOptions);
                    // Setting street view panorama options
                    getPanorama().setOptions(options);
                    // Setting initial position of the street view
                    getPanorama().setPosition(map.getCenter());
                    // Creating point of view object
                    StreetViewPov pov = new StreetViewPov(map);
                    // Setting heading for the point of view
                    pov.setHeading(270);
                    // Setting pitch for the point of view
                    pov.setPitch(20);
                    // Applying the point of view to the panorama object
                    getPanorama().setPov(pov);
                }
            }
        });
    }

    public static void main(String[] args) {
        final StreetViewExample sample = new StreetViewExample();

        JFrame frame = new JFrame("Street View");

        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(sample, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

This example demonstrates displaying traffic layer on the map.

Traffic Layer TrafficLayerExample.java
/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */
package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.*;
import com.teamdev.jxmaps.swing.MapView;

import javax.swing.*;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicTextFieldUI;
import java.awt.*;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * This example demonstrates how to display traffic layer on the map.
 *
 * @author Vitaly Eremenko
 * @author Sergei Piletsky
 */
public class TrafficLayerExample extends MapView {

    private static final String INITIAL_LOCATION = "New York";

    private OptionsWindow optionsWindow;

    public TrafficLayerExample() {
        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Getting the associated map object
                final Map map = getMap();
                // Setting initial zoom value
                map.setZoom(13.0);
                // Creating a map options object
                MapOptions options = new MapOptions();
                // Creating a map type control options object
                MapTypeControlOptions controlOptions = new MapTypeControlOptions();
                // Changing position of the map type control
                controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                // Setting map type control options
                options.setMapTypeControlOptions(controlOptions);
                // Setting map options
                map.setOptions(options);

                // Enabling of traffic layer on the map
                new TrafficLayer(map);

                performGeocode(INITIAL_LOCATION);
            }
        });
    }

    @Override
    public void addNotify() {
        super.addNotify();

        optionsWindow = new OptionsWindow(this, new Dimension(350, 40)) {
            @Override
            public void initContent(JWindow contentWindow) {
                JPanel content = new JPanel(new GridBagLayout());
                content.setBackground(Color.white);

                Font robotoPlain13 = new Font("Roboto", 0, 13);
                final JTextField searchField = new JTextField();
                searchField.setText(INITIAL_LOCATION);
                searchField.setToolTipText("Enter address or coordinates...");
                searchField.setBorder(BorderFactory.createEmptyBorder());
                searchField.setFont(robotoPlain13);
                searchField.setForeground(new Color(0x21, 0x21, 0x21));
                searchField.setUI(new SearchFieldUI(searchField));

                final JButton searchButton = new JButton();
                searchButton.setIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search.png")));
                searchButton.setRolloverIcon(
                        new ImageIcon(MapOptionsExample.class.getResource("res/search_hover.png")));
                searchButton.setBorder(BorderFactory.createEmptyBorder());
                searchButton.setUI(new BasicButtonUI());
                searchButton.setOpaque(false);
                ActionListener searchActionListener = new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        performGeocode(searchField.getText());
                    }
                };
                searchButton.addActionListener(searchActionListener);
                searchField.addActionListener(searchActionListener);

                content.add(searchField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                        GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 0), 0, 0));     
                content.add(searchButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
                        GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(11, 0, 11, 11), 0, 0));

                contentWindow.getContentPane().add(content);
            }

            @Override
            protected void updatePosition() {
                if (parentFrame.isVisible()) {
                    Point newLocation = parentFrame.getContentPane().getLocationOnScreen();
                    newLocation.translate(56, 11);
                    contentWindow.setLocation(newLocation);
                    contentWindow.setSize(340, 40);
                }
            }
        };
    }

    class SearchFieldUI extends BasicTextFieldUI {
        private final JTextField textField;

        public SearchFieldUI(JTextField textField) {
            this.textField = textField;
        }

        @Override
        protected void paintBackground(Graphics g) {
            super.paintBackground(g);
            String toolTipText = textField.getToolTipText();
            String text = textField.getText();
            if (toolTipText != null && text.isEmpty()) {
                paintPlaceholderText(g, textField);
            }
        }

        protected void paintPlaceholderText(Graphics g, JComponent c) {
            g.setColor(new Color(0x75, 0x75, 0x75));
            g.setFont(c.getFont());
            String text = textField.getToolTipText();
            if (g instanceof Graphics2D) {
                Graphics2D graphics2D = (Graphics2D) g;
                graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            }
            g.drawString(text, 0, 14);
        }
    }

    @Override
    public void removeNotify() {
        super.removeNotify();
        optionsWindow.dispose();
    }

    private void performGeocode(String text) {
        // Getting the associated map object
        final Map map = getMap();
        // Creating a geocode request
        GeocoderRequest request = new GeocoderRequest();
        // Setting address to the geocode request
        request.setAddress(text);

        // Geocoding position by the entered address
        getServices().getGeocoder().geocode(request, new GeocoderCallback(map) {
            @Override
            public void onComplete(GeocoderResult[] results, GeocoderStatus status) {
                // Checking operation status
                if ((status == GeocoderStatus.OK) && (results.length > 0)) {
                    // Getting the first result
                    GeocoderResult result = results[0];
                    // Getting a location of the result
                    LatLng location = result.getGeometry().getLocation();
                    // Setting the map center to result location
                    map.setCenter(location);
                }
            }
        });
    }


    public static void main(String[] args) {
        final TrafficLayerExample mapView = new TrafficLayerExample();

        JFrame frame = new JFrame("Traffic layer");

        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(mapView, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Integrating a Google Map into your JavaFX application is easy.

Map Integration MapExample.java
/*
* Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
* Use is subject to Apache 2.0 license terms.
*/

package com.teamdev.jxmaps.examples;

import com.teamdev.jxmaps.ControlPosition;
import com.teamdev.jxmaps.LatLng;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapOptions;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.MapTypeControlOptions;
import com.teamdev.jxmaps.javafx.MapView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;


/**
 * This example demonstrates how to create a MapView instance,
 * display it in JavaFX application and open a simple map.
 *
 * @author Vitaly Eremenko
 */
public class JavaFXExample extends Application {

    @Override
    public void start(final Stage primaryStage) {
        // Creation of a JavaFX map view
        final MapView mapView = new MapView();

        // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and
        // the map object is ready to use. Current implementation of onMapReady customizes the map object.
        mapView.setOnMapReadyHandler(new MapReadyHandler() {
            @Override
            public void onMapReady(MapStatus status) {
                // Check if the map is loaded correctly
                if (status == MapStatus.MAP_STATUS_OK) {
                    // Getting the associated map object
                    final Map map = mapView.getMap();
                    // Creating a map options object
                    MapOptions options = new MapOptions();
                    // Creating a map type control options object
                    MapTypeControlOptions controlOptions = new MapTypeControlOptions();
                    // Changing position of the map type control
                    controlOptions.setPosition(ControlPosition.TOP_RIGHT);
                    // Setting map type control options
                    options.setMapTypeControlOptions(controlOptions);
                    // Setting map options
                    map.setOptions(options);
                    // Setting the map center
                    map.setCenter(new LatLng(35.91466, 10.312499));
                    // Setting initial zoom value
                    map.setZoom(2.0);
                }
            }
        });

        Scene scene = new Scene(new BorderPane(mapView), 700, 500);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Getting Help

Contact Support

During evaluation period please use the email address, provided to you in the evaluation email.

If you have an active support subscription, please use the email address, provided to you in the email confirming the licence purchase.

Ask a Question

We answer questions with #jxmaps tag on Stack Overflow.

Evaluation SupportProvided for 30 days

Support Evaluation

Standard SupportProvided for one year with 25% discount for renewal

Support Standard

Premium SupportContract-based time and materials service

Support Premium
Help with the product use Help with the product use Help with the product use
Response within one business day Response within one business day Response within one business day
Provided by email Provided by email Phone, chat and remote desktop
Product updates Product updates
Feature development
Priority issue resolution
Evaluate for Free Request Renewal Request Premium

Licensing and Pricing

Product licence agreement  ∙  LGPL compliance

JxMaps is using Webkit and FFmpeg components, supplied under LGPL.

  • Perpetual Licence Perpetual licence
  • Free Distribution Free distribution within your application
  • Support Updates 1 year Support and updates
  • 25% Discount Support renewal with 25% discount
  • 15% Discount 15% discount on TeamDev products

Per Developer $799

  • Developer 1 developer
  • Unlimited Projects Unlimited projects
  • Support 55 hours of support for 1 year
Buy Now

Project $2,299

  • Developers Unlimited developers
  • Project 1 project
  • Support 75 hours of support for 1 year
Request Licence

Company-wide $7,299

  • Developers Unlimited developers
  • Unlimited Projects Unlimited projects
  • Support 200 hours of support for 1 year
Request Licence

Source Code For 1 Developer

$9,729 1 Per Developer licence included
Developers Licence for more developers
is also available for purchase

Frequently Asked Questions

Technical Questions

JxMaps supports Windows XP SP2, 7, 8, Server 2008, Server 2012, macOS 10.8 - 10.12, Ubuntu 10 and higher; Oracle and Apple JDKs 1.6 and higher, 32-bit and 64-bit architectures.

Yes, you can use JxMaps in Java Applet and JWS applications like a standard Java library.

You can find examples in JxMaps distribution package and online in JxMaps repository on GitHub.

Licensing Questions

You only need to purchase 2 licences. We licence our library by the number of people who write code using our library.

You can distribute unlimited number of copies of your product with our library enclosed.

All JxMaps updates, both major and minor issued during the active Standard Support subscription period, are free of charge.

You may want to purchase a Project licence, which is cost-effective in case there are 3 and more developers on the team. The Project licence is bound to a single project you do, but it allows any number of developers in your company to work with our library.

The fully-qualified name for a class is the package name followed by the class name, separated by a period (.). For example: com.mycompany.myproduct.MyClass

This can be any class of your application. The only requirement is that it should be included into your Java application class path.

When we say “project” we have in mind one product of your company, including your future product versions or potential derivative works, based on your product.

The Project licence is tied to one project only.

The best solution would be to purchase a Company–wide licence, which covers any number developers and projects in one company.

Upon the licence purchase you will receive a licence archive. The archive will contain a licence.jar file. This licence should be used in the development process and included in your application when distributing it to end users. Inside the licence.jar you can find the teamdev.licenses file that contains information about your licence.

Yes, you can purchase JxMaps Source Code Licence; it is provided on a per developer basis. Please contact our sales team if you are interested in this option.

If you are doing an open source or academic project, you can apply to get a free licence. Please submit a request via Open Source or Academic tab on the evaluation form.

Chromium code is mainly provided under a permissive BSD licence, however, some components it includes are supplied under different licences. We have reviewed the licences for all components included in JxMaps and referenced them here. There are no requirements to disclose your proprietary code.

Thank you!

Start your free trial in few simple steps

1
Email

Check Your Email

Links to download your evaluation licence and distribution archive will arrive at your inbox in a few minutes.

If the message gets lost in your mailbox, try searching for an email from JxMaps Evaluation Support with “Your Free 30 Days Trial” subject.

2
Licence

Install the Licence

To start using JxMaps

  • download your evaluation licence,
  • download and extract the distribution archive,
  • include all the JAR files from the lib directory and evaluation licence licence.jar in your application class path.
3
Start

Get Started

Use these guides to get JxMaps up and running in no time:

JxMaps Swing Quick Start Guide

JxMaps JavaFX Quick Start Guide

Working with JxMaps in popular IDE:

JxMaps in IntelliJ IDEA

JxMaps in Eclipse

JxMaps in NetBeans

Examples

Check out the ready-made examples for instructions and ideas on what you can do with your newly gotten JxMaps.

Evaluate

Commercial Open Source Academic

With this licence you will be able to evaluate our product for 30 days.
The evaluation licence will not work after this time, so you will need to purchase the licence.

With this licence you will be able to evaluate our product for 30 days.
The evaluation licence will not work after this time. If you are doing an open source project, you can request a permanent licence via the link provided in the email you will receive.

With this licence you will be able to evaluate our product for 30 days.
The evaluation licence will not work after this time. You can request a licence for duration of your academic project via the link provided in the email you will receive.

You should have an existing open source project which has commits and some life period of the project.

We can provide licences only for projects distributed under non-viral licence (LGPL, Apache, etc.). Our library is proprietary and we will not be able to disclose its code.

Technologies and Platforms
Please list other technologies, it may help in support.