dlsc-software-consulting-gmbh / gmapsfx Goto Github PK
View Code? Open in Web Editor NEWJava API for using Google Maps within a JavaFX application.
Home Page: http://rterp.github.io/GMapsFX/
License: Apache License 2.0
Java API for using Google Maps within a JavaFX application.
Home Page: http://rterp.github.io/GMapsFX/
License: Apache License 2.0
Add the ability to drop a marker on the map.
When panning the Map in an application running on the Map there is persistent flickering.
I've just tried out your library and it's perfect for a project I'm working on. I have two questions, though:
Thanks in advance.
Hi,
I would like to know if this API has some geolocation services ? and if not could yu make one or show us how to use your package to make one.
By the way, Thx for this great library and the greatness it offers ^^
Hi,
I have a startpoint and endpoint in LatLong, i want to draw path between those points but i want the path to be on streets/roads instead going through buildings/rivers. Is there any option of Polyline to do that ??
Something similar to snap to roads ?? [https://developers.google.com/maps/documentation/roads/snap#request](snap to road)
Add support for Info Windows to Markers.
https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple
Fix classes so that the GMapsFX jar can be added to SceneBuilder so that the GoogleMapView component can be added to the component palette.
Create new entity (JavascriptEnum) to map to a enumeration in the Javascript environment.
Add the ability to fire an onClick event from the GoogleMapView back to Java.
https://developers.google.com/maps/documentation/javascript/examples/event-simple
I use GMapsFX 1.1.1
I try to add a Polyline to GoogleMap with this code:
LatLong ll1 = new LatLong(47.6197, -122.3231);
LatLong ll2 = new LatLong(47.6297, -122.3431);
LatLong[] ary = new LatLong[]{ll1, ll2};
MVCArray mvc = new MVCArray(ary);
PolylineOptions polyOpts = new PolylineOptions()
.path(mvc)
.strokeColor("red")
.strokeWeight(2);
Polyline poly = new Polyline(polyOpts);
map.addMapShape((MapShape) poly);
In the last line of code I get a compilation error because the polyline is not an instance of MapShape.
Where is the mistake?
Needs some further testing, but I think there might be trouble with this, as I'm left with a view without tiles (but still has Google decorations) when I call setMapTypeId.
Hello,
i need a kind of a car navigation in my java application.
The GMapsFX has every feature i need and its very simple! Great Job!
But, i have a big memory Problem
I create every seconds a new Geo-Position (Lat and Long) and send it to my MapPresenter.
An handlePositionEvent - Methods accept the new position and creteas a new Marker. I cache the previous marker
private Map<String, Marker> carMarkerMap = new HashMap<String, Marker>();
private GoogleMap map;
@Subscribe
public void handlePositionEvent(PositionEvent event) {
if (mapIsReady) {
Platform.runLater(new Runnable() {
@Override
public void run() {
// creates a NEW marker
Marker marker = createCarMarker(event.getCarName(),
event.getLatitude(), event.getLongitude());
String carName = event.getCarName();
if (carMarkerMap.containsKey(carName)) {
System.out.println("remove marker");
Marker m = carMarkerMap.get(carName);
map.removeMarker(m);
carMarkerMap.remove(carName);
m = null;
}
map.addMarker(marker);
carMarkerMap.put(carName, marker);
}
});
}
}
But i think, the Marker-Objects would not be destroy. After about 300 Markers, the application need 1 GB.
Does i make an misstake, or is it a bug?
thx
Hi,
I really like GMapsFX, but everyone should know that the terms of service of google has to be accepted when using it!
E.g. https://developers.google.com/maps/faq#understanding-terms-of-service
That is a reason why we can not use GMapsFX in our JavaFX application -> our application is not full featured "publicly accessible".
That should be mentioned e.g. in the license section of the GMapsFX README.md.
Best regards
Hello,
if I start an application with a GoogleMapView inside and without internet connection at startup and I resize the stage a NPE is thrown
java.lang.NullPointerException
at com.lynden.gmapsfx.GoogleMapView.mapResized(GoogleMapView.java:101) ~[GMapsFX-1.1.2.jar:?]
at com.lynden.gmapsfx.GoogleMapView.lambda$new$3(GoogleMapView.java:81) ~[GMapsFX-1.1.2.jar:?]
at com.lynden.gmapsfx.GoogleMapView$$Lambda$576/1519827285.invalidated(Unknown Source) ~[?:?]
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349) [jfxrt.jar:?]
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) [jfxrt.jar:?]
at javafx.beans.property.ReadOnlyDoubleWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyDoubleWrapper.java:177) [jfxrt.jar:?]
at javafx.beans.property.ReadOnlyDoubleWrapper.fireValueChangedEvent(ReadOnlyDoubleWrapper.java:143) [jfxrt.jar:?]
at javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113) [jfxrt.jar:?]
at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:147) [jfxrt.jar:?]
at javafx.scene.web.WebView.resize(WebView.java:304) [jfxrt.jar:?]
at javafx.scene.Node.resizeRelocate(Node.java:2920) [jfxrt.jar:?]
at javafx.scene.layout.AnchorPane.layoutChildren(AnchorPane.java:363) [jfxrt.jar:?]
...
Create documentation on GMapsFX usage including how the framework is interacting with Javascript, and when and how Javascript objects can be created.
Add the ability to draw a polyline on a map.
https://developers.google.com/maps/documentation/javascript/examples/polyline-simple
The FireBug pane is showing in the WebView by default. Change the GoogleMapView to take a boolean argument to run in debug mode and display the FireBug pane.
Seems to me that com.lynden.gmapsfx.javascript.object.GoogleMap getLatLong() creates a ClassCastException and is obsolete anyway.
Is it possible to use StyledMaps in GMapsFX (http://developers.google.com/maps/documentation/javascript/styling)? If yes, how can one achieve this? Would be nice if there is a simple function to apply a style by providing a Style array (like those found here http://snazzymaps.com/explore). Thanks
Ensure all classes and packages have Javadoc documentation.
Add the ability to pass in an API key for those who are using Google Maps for Business.
Add com.lynden.gmapsfx.MainApp in jar Manifest so example application can be executed by double clicking the .jar file.
Hi,
Is there a way (by code) to change the maps.html basic layout to 100% of map (instead of 75% map and 25% directions)?
Thx!
Add ability to drop a marker on a map.
Hi,
just wanted to know if i could have a searchbox in the map to search places. how do i do that?
and thanks for this gmapsfx, it really helps a lot.
Hello @rterp,
I am unable to set the bounds (fitBounds) of the Gmap. When I pull your Git, there is no problem with that, but the function is not available in the maven-dependency. Is there a way so solve this?
Regards,
klemensh
Add a CloseClick UI Event which will be fired when an InfoWindow is closed.
Move the JavaScript Runtime classes to a new project so they can be used for other JavaScript enabled web applications other than Google Maps.
Markers that have been removed from the map instance are not removed from the display of the map (they disappear once the map has been zoomed or panned beyond the current window).
As with the previous issue raised, the Marker Options cannot be updated to allow the marker to be made invisible then removed as a workaround.
Is there a way to refresh to map to remove redundant markers?
Only one marker appears on a map no matter how many are actually added. The following code only displays 1 marker, even though 2 are added.
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position( new LatLong(47.6, -122.3) )
.visible(Boolean.TRUE)
.title("My Marker");
MarkerOptions markerOptions2= new MarkerOptions();
markerOptions2.position( new LatLong(47.701, -122.3) )
.visible(Boolean.TRUE)
.title("My Marker2");
Marker marker = new Marker( markerOptions );
Marker marker2 = new Marker(markerOptions2);
map.addMarker(marker);
map.addMarker( marker2 );
When panning and zooming a map I get this exception:
java.lang.IllegalArgumentException: Image dimensions must be > 0
at com.sun.prism.Image.(Unknown Source)
at com.sun.prism.Image.(Unknown Source)
at com.sun.prism.Image.fromByteBgraPreData(Unknown Source)
at com.sun.javafx.webkit.prism.RTImage.getImage(Unknown Source)
at com.sun.javafx.webkit.prism.PrismImage.getPlatformImage(Unknown Source)
at com.sun.javafx.webkit.UIClientImpl.startDrag(Unknown Source)
at com.sun.webkit.WebPage.fwkStartDrag(Unknown Source)
at com.sun.webkit.WebPage.twkProcessMouseEvent(Native Method)
at com.sun.webkit.WebPage.dispatchMouseEvent(Unknown Source)
at javafx.scene.web.WebView.processMouseEvent(Unknown Source)
at javafx.scene.web.WebView.access$2500(Unknown Source)
at javafx.scene.web.WebView$14.handle(Unknown Source)
at javafx.scene.web.WebView$14.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1800(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" E
Add ability to draw a route on a map similar to what you would see when you plot directions on Google Maps.
There is not a lot of information on the expectation of the scope of the icon property in MarkerOptions; I am attempting to pass it a path to a PNG image in the resources but nothing is appearing when adding the marker to the map.
In the code snippet below, if the icon method is removed, then the default marker icon is displayed.
MarkerOptions immediateMarkerOptions = new MarkerOptions();
immediateMarkerOptions.position( latLong );
if ( currentMode == SimulatorModes.immediate )
{
immediateMarkerOptions.icon( "images/MarkerGreen.png" );
}
else
{
immediateMarkerOptions.icon( "images/MarkerPin.png" );
}
immediateMarker = new Marker( immediateMarkerOptions );
map.addMarker( immediateMarker );
Currently in order to update the language you must update the maps.html line below:
Take a look at this line: <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=pt-BR"></script>
in this file: https://github.com/rterp/GMapsFX/blob/master/GMapsFX/src/main/resources/html/maps.html
Modify API so that the language could be specified at runtime.
Allow for default animation of Marker drops.
https://developers.google.com/maps/documentation/javascript/examples/marker-animations
All get/set methods in JavascriptObjects should delegate to their underlying JSObject peers.
Hi,
I add two different types of markers to the map. Let's say I add 10 red ones and 10 blue ones.
I have two buttons (red and blue). When I click the blue button, I hide the red markers. When I click the red button, I hide the blue markers. I use marker.setVisible().
This all works, but sometimes I get a problem.
Sometimes, I will click blue to show only the blue markers but some of the red ones are still visible. I think it is just a painting issue because if I zoom in and then zoom back out, they are gone and all is correct again.
So, is there something like map.refresh or map.repaint that I could call after I have set all the visibilities?
Thanks a lot,
Jim
Hello,
We used some code from a previous blog of yours (https://rterp.wordpress.com/2014/04/25/gmapsfx-add-google-maps-to-your-javafx-application/), but when we try to zoom by double-clicking the map, we then cannot drag the map.
Here is a picture showing what happens when we try to drag and move the map after zooming with a double click:
That document image appears, and the map will not drag properly.
We don't see the issue when using the zoom controls.
We are using the most recent release of the jar file, and we are seeing the same issue on Mac and Windows.
Any help would be appreciated!
Thank you!
We redirect sysout's and syserr's to logfiles.
It would be nice if no unnecessary sysout's would be printed :)
E.g.
GoogleMapView.mapResized: triggering resize event
GoogleMapView.mapResized: triggering resize event done
Hi,
I tried your framework, and it's really great.
Currently I'm working on a small GIS project, and I plan to use opensource Geoserver.
I download my country Shapefile from OpenStreetMap ... and deployed it into Geoserver.
My question is: Can I use my own Geoserver to serve map tile for your framework?
If not, could you please state on which class should I re-implement to be able to use my Geoserver instead of Google map?
Thanks
Hi ! In my project when the map starts I add some markers with different images, but the map shows me all the markers with the same icon.
The images are next to html inside the jar.
i have this code in the Main
@Override
public void mapInitialized() {
MapOptions mapOptions = new MapOptions();
mapOptions.center(new LatLong(-37.317314, -59.13849))
.mapType(MapTypeIdEnum.TERRAIN)
.overviewMapControl(false)
.panControl(false)
.rotateControl(false)
.scaleControl(false)
.streetViewControl(false)
.zoomControl(true)
.zoom(16);
map = mapView.createMap(mapOptions);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(new LatLong(-37.317430,-59.138460))
.visible(true)
.title("Point 1")
.icon("images/cerrado.png");
Marker marker = new Marker( markerOptions );
map.addMarker(marker);
MarkerOptions markerOptions2 = new MarkerOptions();
markerOptions2.position(new LatLong(-37.315080,-59.143340))
.visible(true)
.title("Point 2")
.icon("images/obras.png");
Marker marker2 = new Marker( markerOptions2 );
map.addMarker(marker2);
}
but when i refresh the map (doing zoom) i get this
do you know if this is a bug or i 'm doing things in the wrong way?
Thanks
Hi Rob,
I've put in some sloppy handling of return values throughout that need to be tidied up. In most cases the return value should be the class type of the primitive, so where I'm returning double it should be Double. My question is about booleans... Return false if it's null? Or should we return Boolean which will be more accurate, but introduce the need for extensive null tests throughout the code before we use any boolean value.
I'd suggest Booleans from anything that's going to be in the Javascript library as we wouldn't want to surprise end-users, but for the Google Maps stuff it's often settings, so for example if getEditable returns null, it may as well be false.
What are your thoughts?
Within the Gluon compile environment, the desktop version (Windows 10/JDK 8u66) runs very well. However when I deploy and tried running in the S5 Android phone, the JavaFX WebView displays the following: "Web Page not available, net::ERR_UNKNOWN_URL_SCHEME".
It may be that the Android JavaFX Webview treats the embedded maps.html differently from the way the Windows 10 JavaFX Webview component does.
It I instantiate JavaFX Webview and passes in a web URL, both the Windows 10 and Android environment runs identically without any issues.
Calls to getDuration() and getInstructions() Direction-related functions are always returning null.
Hi,
Im busy with a school project but im trying to get a custom marker icon but it doesn't work.
I placed the image in rescources/html/images/marker-green.png
and i used .icon("images/spotlight-green.png")
can you help me?
Currently the scrollpane is enabled by default due to the following line.
Make the scrollpane configurable at runtime via the API
Hi,
More of a question than an issue, library works great.
It's just when you click the zoom button a couple of time or use scroll wheel on mouse to zoom, the map crashes and UI becomes unresponsive. Exceptions being thrown are
From Googling, it seems this could be an issue with the JavaFX webview itself. Although, most of the issues are closed and JavaFX say the issue has being resolved.
So I'm just wondering if you guys came across this and would have any advice on how to workaround it:)
I'm thinking I could disable the scroll wheel and try prevent user from clicking zoom button too often!! Lost to be honest, would adding these 2 vm arguments help
-Dprism.order=sw
-Xmx2048m
A Marker object is instantiated with a MarkerOptions object; once this the Marker is instantiated, the options cannot be accessed. The options contain a visible setting that is unsettable once associated with a Marker which seems incorrect.
Is there any way to get current location of the user? Like Google detects from user's browser ??
Hi,
I was experimenting with the code. May i know, how can i get latitude and longitude of the location where i click on map ??
And thanks for the nice project ๐ !!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.