Qt4 Google MapView
July 12, 2009 | Filed Under Qt4 | No CommentsI’ve received a couple of requests about Google Maps and Qt4. Today I’ve written a simple Widget that allows you to interact with Google Maps and Google Geocoder. You can set Map Type (Roadmap, Satellite, Terrain and Hybrid), you can set your center Coordinate, add Markers, add Info Windows get the User Click Coordinates and other things that Google Maps allows to do.
With few lines of code, you can interact with Google Maps, and below you can see how to do it. (Other methods and overloads are available, check the GKMapView.h in the Source Code packet, link is at the end of the post).
GKMapView mapView;
// Change the Default MapType (Roadmap, Satellite, Terrain, Hybrid)
mapView.setMapType(GKMapTypeSatellite);
// Use Geocoder to Get Location from Address or Viceversa.
// See the Signals locationFound, locationNotFound() and
// addressFound(), addressNotFound() to get your results.
mapView.locationFromAddress("San Mateo");
mapView.addressFromLocation(32.718834, -117.164);
// Add Marker With Info Window at Specified Address (or Location)
mapView.addMarkerWithWindow("Bedford MA Marker",
"<b>Bedford MA</b> Marker",
"Bedford MA");
// Add Info Window without Marker using Address or Coordinates
mapView.addInfoWindow("Hello from <b>San Mateo</b>", "San Mateo");
mapView.addInfoWindow("Hello from <b>San Diego</b>", 32.718834, -117.164);
// Change your Current Location
mapView.setLocation("Phoenix AZ");
The Source Code is available Here with a small example: Qt4 Google Map View Source Code.


