Pushpin Collections *NEW
API Catalog
API Blog
Getting Started
More Examples
Dynamic Layers API Examples
Widgets
Overlay Sets and Filtering *NEW
Class Reference
Extended Class Reference
Contact us
(c) 2008 Placebase, Inc.
|
Browse Pushpin Collections for data from ESRI, Claritas, NAVTEQ and more!
View the Pushpin API Blog for the latest updates.
View Documentation for Version 1.3 Version 1.2 Version 1.0 Version 0.9 Version 0.8
If you're unsure which version of the API you're using, use the global function PGetVersion().
Getting Started
Placebase's Pushpin provides an easy to use JavaScript Application Programming Interface (API) for
embedding scrollable maps into your website. The following code example shows
how to create a 500x300 pixel scrollable map centered on Los Angeles:
Pushpin JavaScript API Example: Getting Started
Here is a link to a page where you can view this example in action ( start.html).
The URL in the example above, http://api.pushpin.com/js?key=7317C398726C3B4530DFD15363895140,
is the location of the pushpin code. In order for that URL to work,
you will need a valid key value. Upon subscribing
to Pushpin you will receive a key. This key will only work for web pages served from your site.
Getting a Map
As shown in the Getting Started example above, getting a map consists primarily of two
lines of JavaScript code, one to construct the PMap object, and another to
center and zoom the map at a particular geographic coordinate (34.045, -118.235) at zoom level 13:
var map = new PMap(document.getElementById("map"));
map.setCenter(new PLatLng(34.045, -118.235), 13);
View example (start.html)
Adding a Pin to the Map
The PMarker object is used to add a Pushpin to a point on the map.
View example (addpin.html).
The example above uses the same method as the Getting A Map example to center and zoom the map to a
geographic coordinate (34.045, -118.235), but also adds a point to the map. The PMarker
constructor takes a PLatLng object. Once created, the marker is added to the map
using the map.addOverlay() method. The following two lines of code from
this example creates a marker at a given point, and overlays that marker on the map:
var marker1 = new PMarker(point1);
map.addOverlay(marker1);
Adding Controls to the Map
The map object offers methods that overlay a variety of controls on the map. The following
example shows how to add simple zoom in / zoom out and pan controls to the map.
View example (smallmapcontrol.html).
The example above shows how to add a small map control (PSmallMapControl) to the map.
The control allows users to zoom and pan. The following line of code adds the control to the map:
map.addControl(new PSmallMapControl());
Other types of controls can also be added to the map, such as PLargeMapControl and PSmallZoomControl. Click here for all controls supported by the API.
Opening an Info Window
Information windows that appear as cartoon-like bubbles can be displayed on the map.
In their simplest version, these windows contain text.
View example (infowindow.html).
The above example shows how to add a simple info window to the map. The following line opens
the window.
map.openInfoWindow(map.getCenter(),
document.createTextNode("Hello, world!"));
Adding Overlays to the Map
Many overlays can be added to the same map. The following example loops through
and adds 10 random pins, 4 lines and a triangle to the map .
View example (overlay.html).
Handling Clicks
Points can be added to the map via clicks using event listening. The following example
shows how to support adding markers to the map at whatever point a user clicks.
View example (click.html).
The addListener function waits for a user click, at which point a new
PMarker is added to the map.
PEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
map.removeOverlay(overlay);
} else if (point) {
map.addOverlay(new PMarker(point));
}
});
Attaching Events
In addition to clicks, other events can also be attached and handled with the event listener. The following example prints
out several events as they occur. Click here for a list events that can be attached to PMap.
View example (events.html).
Opening an Info Window above a Marker
Info windows can be added to markers themselves in order to annotate the pins.
View example (infowinmarkup.html).
The addListener function is used to add a listener to a specific PMarker
object called marker.
PEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
The following example adds info windows above multiple markers.
View example (infowinmarkers.html).
Tabbed Info Windows
Multiple tabs can be created for info windows. The following example shows how to open an info window with 2 tabs above a marker.
View example (tabs.html).
// Create tabs
var infoTabs = [
new PInfoWindowTab("Tab 1", "This is content for Tab 1"),
new PInfoWindowTab("Tab 2", "This is content for Tab 2")
];
// Add marker and open info window
var marker = new PMarker(map.getCenter());
PEvent.addListener(marker, "click", function() {
marker.openInfoWindowTabsHtml(infoTabs);
});
map.addOverlay(marker);
marker.openInfoWindowTabsHtml(infoTabs);
Creating Custom Icons
You can use your own custom icons on the maps using Pushpin. Setting the PIcon properties like
image and (optionally) shadow to a URL pointing to the image to use will enable overlay of custom images on the map.
Click here for a list of predefined icons from Pushpin.
View example (icon.html).
Getting Multiple Maps on One Page
Multiple maps can be configured to appear on the same page as in the following example:
View example (multimap.html).
Each map is declared as a separate variable (in this case map and map2),
and each can be controlled distinctly by its handle.
var map2 = new PMap(document.getElementById("map2"));
map2.setCenter(new PLatLng(33.952, -118.155), 6);
Geocoding (Converting an Address to a Point)
The process of taking an address and converting it to a geographical point is called Geocoding.
As shown in the example below, the showAddress function takes an address and adds a marker to that point.
Geocoding is an inherently messy process and often addresses will not resolve to specific coordinates. Therefore showAddress checks to see if the
point returned is valid. The getLatLng function needs to be passed a callback function to be called after the response comes back.
View example (geocode.html).
Finding a Place (Geographic Boundary)
The Pushpin API contains different types of places (PPlaceType), which are geographic boundaries like state, county or zip codes.
Click here for a list of the current place types supported.
These are primarily used with thematic data to determine the appropriate type to use per zoomlevel.
The specific place (PPlace), e.g. Los Angeles County or 90013, contains information like the name, type, bounding box, centroid and area, and can also be used to find the value of an indicator for the place.
The following example shows how to search for a place using PClientGeocoder.getPlace(). It uses the vertices returned to highlight the matching place.
View example (findplace.html).
Using XML
The Pushpin API contains classes and methods that load and parse XML files in the latest browsers. For example, PXmlHttp.create() creates a new instance of a browser independent XmlHttpRequest. The following example shows how to download a static XML file (data.xml), parse it and create markers and info windows with the information.
View example (xml.html).
The function PDownloadUrl is used to download the data asynchronously and PXml is used to parse the XML.
// Download the data in data.xml and load it on the map.
PDownloadUrl("data.xml", function(data, responseCode) {
var xml = PXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new PLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = PXml.value(markers[i].getElementsByTagName("label")[0]);
html += " " + PXml.value(markers[i].getElementsByTagName("description")[0]);
map.addOverlay(createMarker(point, html));
}
});
Managing Markers
Displaying hundreds of markers on a map can cause slow downs. To make these maps more efficient, use PMarkerManager to manage markers on a map.
PMarkerManager automatically groups markers into clusters depending on the number of markers currently in the map view and only draws markers that are located within the map view.
The following example demonstrates this. You will see that some of the markers are clustered. Clicking on the clustered markers will display an info window stating how many markers it represents.
Zoom in to see the individual markers. You can also zoom out until all markers are represented by one cluster marker.
View example (markermanager.html).
Create a new PMarkerManager.
var markerManager = new PMarkerManager(map);
Add markers to the map using the addMarker() function.
markerManager.addMarker(createMarker(point, i + 1));
Printing Map Images
The Pushpin API allows you to save a map as one image for printing purposes. The following example provides a link that opens an image of the current map in a new window, with the specified size of 500x500 pixels. If the size is not specified, the current map view size will be used. Optional center and / or zoom level parameters can be added too, otherwise the current zoom level and center of the map will be used.
View example (printmap.html).
The following code returns the URL of the image.
map.printImage(new PSize(500,500));
The window.open function opens this URL in a new window.
Using a Different API Version
To upgrade to a new API version, you can contact us to update your key to point to the new version.
An easy way to test this out first, would be to use an existing API key and pass in the v parameter in the url's query string. You can use the method PGetVersion if you're not sure what version you have.
Here's an example script tag that uses version 1.0 of the API rather than the latest and greatest:
View example (version.html).
Pushpin map images are constituted of familiar map elements such as parks, streets, and labels
that are known as GIS layers. The Pushpin Dynamic Layers extension has functions that support control
over the layers that make up the basemap image. By default, GIS layers are merged on the server-side before being handed
over as a single set of tiles (though they can be sent to the client as separate layers as well).
The Dynamic Layers API extension supports mapping, toggling on and off standard layers, and reordering layers in the stack.
As such several, new classes are available through the API (such as PMapLayer -- see class reference below),
and new functions have been added to some existing classes (such as PMap).
Toggling Map Layers Off
The following example shows how to toggle a layer within the stack of GIS layers that make up the
image. In this example the PMapLayer.POLY, which contains polygons like parks and
water bodies, is switched off. Click here for a list of available layers.
// Turn off poly layer
PMapLayer.POLY.off();
You can also access the PMapLayer objects in a PMapType to see what they are.
// Get the array of PMapLayer objects in the current PMapType and display
var layers = map.getCurrentMapType().getMapLayers();
var layerlist = "";
for (var i=0; i<layers.length; i++)
layerlist += layers[i].getLabel() + ": " + layers[i].isOn() + "\n";
alert (layerlist);
View example (layers.html).
Creating a Custom Map Type
The following example shows how to create a custom map type using predefined layers and add it to the map. Custom layers can be created with Rendermap
and the layer object made accessible. Click here for a list of currently available layers.
// Create custom map layers and map types
var base = new PMapLayer(PMapLayer.BASE);
var pointline = new PMapLayer(PMapLayer.POINTLINE);
var maptype = new PMapType([base,pointline]);
Custom scales for a map type can also be defined (in descending order). The following shows how this is done (the first scale in the array is zoom level 0). Click here for a list of currently available scales.
// Create custom scales
maptype.setScales([4608000, 2304000, 1152000, 576000, 288000, 144000, 72000, 36000, 18000]);
The following sets the map to view the custom map type.
// Set map type
map.setMapType(maptype);
The following shows how to add a layer after a map type has been created.
// Add another map layer (predefined) on top
maptype.addMapLayer(PMapLayer.CITIES);
You can also change the opacity of map layers.
// Change opacity of cities layer
PMapLayer.CITIES.setOpacity(0.5);
View example (maptype.html).
Adding Thematic Variables to the Map
Thematic mapping refers to color-coding of the map by region. Variables can be added to maps using the
PIndicatorLoader class. Click here for our catalog of indicators and datasets from a variety of sources including ESRI, Claritas and Census.
Value-added market information data can be purchased separately in transaction bundles.
The following example is a quick way to underlay a thematic variable on a map.
// Add indicator to map with ID
map.setIndicatorById(168064);
View example (thematic.html).
Another way to add indicators is by loading the indicators first using PIndicatorLoader. The following example shows how to do this.
function onLoad() {
// Load indicator
PIndicatorLoader.load([168002,168524,168064],loadIndicators);
}
function loadIndicators(indicators) {
...
// Add indicator to map
map.setIndicator(indicators[1]);
}
View example (thematic2.html).
Changing Thematic Colors on the Map
The thematic shading colors or color ramp can be changed. The default is a predefined green color ramp. Click here for a list of predefined color ramps.
The following example shows how to create a custom color ramp and apply it to the map.
// Create custom color ramp
var mycolorramp = new PColorRamp('mine',
[new PColor('F26522'), new PColor('F68E56'), new PColor('FBAF5D'), new PColor('FFF200'),
new PColor('ACD373'), new PColor('A3D39C'), new PColor('7ACCC8'), new PColor('6DCFF6')]);
// Set map's legend to new color ramp
map.getLegend().setColorRamp(mycolorramp);
View example (colorramp.html).
Changing the Number of Thematic Breaks
The number of breaks or ranges can be changed for thematic layers. The default is 8. Valid values are from 3 to 8. The following example shows how to change the number of breaks on the map.
// Set map's legend with new number of breaks
map.getLegend().setNumberOfBreaks(4);
View example (breaks.html).
Merging Map Layers on the Client Side
By default, map layers are merged on the server side into a single tileset before being handed over
to the browser. This is usually the best method for typical maps. Occasionally, it will make more sense to do certain overlays on the client side
Some applications may involve users frequently toggling map layers on and off at a single location, which
would see performance advantages because individual tiled map layers get stored on the client. However,
the more layers that get merged on the client side will cause slower map loads and dragging. This
example shows how to change the default behavior, by making the city map layer merge on the client side.
Notice that the toggling of the city layer is much faster, and doesn't cause the tiles to be reloaded.
// Merge city layer on client side
PMapLayer.CITIES.mergeClient();
A similar method can be used to set all map layers in a maptype to be merged client or server side, e.g. PMapType.NORMAL.mergeClient(). Layers can be set differently to create a hybrid of client / server side merged layers.
View example (mergeclient.html).
The Pushpin API provides the ability to add and embed custom and predefined widgets that control the map. Click here for a list of predefined widgets.
These widgets can be dragged, collapsed and closed like standard windows. As well, the content in these widgets will update appropriately when certain functions are called.
For widgets to work, the map object must first be declared globally, outside of the onLoad function e.g. var map = null.
Adding a Widget
Adding a widget is similar to embedding a map. The following example shows how to add a custom widget next to the map.
View example (widget.html).
Adding Predefined Widgets
The Pushpin API has a library of predefined widget IDs. The following example adds the map layer widget. This widget allows you to toggle the map layers in the current map type.
// Creates a map layer widget
var widget1 = new PWidget(map, document.getElementById("widget1"), P_WIDGET_LAYER_ID);
The following example demonstrates how to add the thematic widget for choosing indicators. A list of indicators should be set when creating the widget. Click here for a list of available indicators.
This widget will update the indicator, color ramp and breaks automatically if they are changed.
// Creates an indicator chooser widget for displaying thematic data
map.setIndicatorListByIds([168002,168524,168064]);
var widget2 = new PWidget(map, document.getElementById("widget2"), P_WIDGET_INDICATOR_ID);
View example (widgets.html).
Customizing Widget Styles
You can customize the look and feel of a widget by modifying CSS style objects for different parts of the widget. Click here for a list of properties that are customizable.
The following example shows a widget with a different style and added on top of the map.
// Modify widget style
widget.background.style.backgroundColor = "#EFB500";
widget.background.style.border = "1px solid #333";
widget.box.style.border = "1px solid #cc6600";
widget.heading.style.backgroundColor = "#E78418";
widget.heading.style.border = "1px solid #cc6600";
View example (widgetstyle.html).
The Pushpin API provides the ability to group overlays, such as markers and polylines, into sets which can then be turned on and off like layers.
As well, markers and polylines can have attributes and when added to a set, filters can be applied which query by these attributes.
Adding Overlay Sets
The following example adds a set of random markers and a set of random polylines to the map, and adds the predefined overlay sets widget to control them.
// Create overlay sets and set labels
var markerSet = new POverlaySet(markers);
markerSet.setLabel("Markers");
var polylineSet = new POverlaySet(polylines);
polylineSet.setLabel("Lines");
// Turn polyline set off by default
polylineSet.off();
// Add sets to the map
map.setOverlaySets([markerSet,polylineSet]);
// Display sets in widget
var widget = new PWidget(map, document.getElementById("widget"), P_WIDGET_OVERLAY_ID);
View example (addset.html).
Adding Attributes and Filters
The following example assigns an attribute to random markers and adds it to a set. It also defines some filters to be called on the set. Click here for types of attributes and filters available.
View example (addfilter.html).
Displaying Filters
The following example creates two random marker sets and sets some filters for display in the overlay set widget.
View example (addfilterdisplay.html).
Adding Predefined Marker Sets
You can add predefined marker sets to the map, that get rendered on the server side when dealing with large amounts of pins (in the thousands).
Using a different constructor for POverlaySet, you can specify the ID of the predefined set.
markerSet = new POverlaySet(500);
Click here for our catalog of point datasets from a variety of sources including NAVTEQ.
The markers get rendered on the server as a separate layer and merged on the map when there are too many markers in the map view (default threshold is 50), otherwise markers will be added on the client side.
In addition, there is also a zoom level threshold (default is 12) that can be specified too, for when the switching between server side and client side markers takes place.
Therefore, to identify markers, you need to check if there is a PMarker on the map (client side) and if not, use the identify function to see if there is marker where you clicked. Here is an example of how to do this.
// Attach click event to identify marker
PEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
var attributes = overlay.getAttributes();
overlay.openInfoWindowTabsHtml(printAttributes(attributes));
}
else {
map.identify(point, function(markers) {
if (markers.length > 0) {
var attributes = markers[0].getAttributes();
map.openInfoWindowTabsHtml(markers[0].getPoint(), printAttributes(attributes));
}
});
}
});
Predefined marker sets have attributes attached to the individual markers. You can see these when you click on the metadata for the marker set in the catalog.
These can then be used to filter the markers, using the attribute column name.
// Create filters for overlay set
var filter1 = new PAttributeFilter("Facility Type", [9121], PAttributeFilter.EQUAL,
"City Hall", "fac_type", PAttribute.NUMBER);
var filter2 = new PAttributeFilter("Facility Type", [7994], PAttributeFilter.EQUAL,
"Civic/Community Center", "fac_type", PAttribute.NUMBER);
var filter3 = new PAttributeFilter("Facility Type", [9211], PAttributeFilter.EQUAL,
"Court House", "fac_type", PAttribute.NUMBER);
var filter4 = new PAttributeFilter("Facility Type", [9221], PAttributeFilter.EQUAL,
"Police Station", "fac_type", PAttribute.NUMBER);
markerSet.setDisplayFilters([filter1, filter2, filter3, filter4]);
View example (addserverset.html).
The following tables list the classes and methods currently available through the
Pushpin API. Classes or methods that are only available as part of the Dynamic Layers
API extension have a light green background.
Class: PMap |
| Method |
Return |
Description |
Example |
new PMap(container, logo) |
PMap |
The constructor. Creates a new map object within the HTML container, normally a div element. An optional logo (HTML DOM node) can be specified, which appears on the bottom right of the map, otherwise the default Pushpin logo will be used. Use a blank node as an argument if no logo is desired. |
start.html |
enableDragging() |
none |
Enables dynamic dragging of the map (enabled by default). |
enabledragging.html |
disableDragging() |
none |
Disables dynamic dragging of the map. |
mergeclient.html |
draggingEnabled() |
Boolean |
Returns true if dragging is enabled, false if dragging is disabled. |
enabledragging.html |
enableInfoWindow() |
none |
Enables display of the info window on the map (enabled by default). |
|
disableInfoWindow() |
none |
Disables display of the info window on the map. |
|
infoWindowEnabled() |
Boolean |
Returns true is info window is enabled, false if info window is disabled. |
|
enableDoubleClickZoom() |
none |
Enables double click to zoom in (disabled by default). Double right mouse click zooms out. The default double click recenters the map on the point. |
doubleclickzoom.html |
disableDoubleClickZoom() |
none |
Disables double click to zoom in and out. |
doubleclickzoom.html |
doubleClickZoomEnabled() |
Boolean |
Returns true if double click to zoom is enabled, false otherwise. |
doubleclickzoom.html |
enableScrollWheelZoom() |
none |
Enables zooming in and out using the mouse scroll wheel (disabled by default). |
|
disableScrollWheelZoom() |
none |
Disables zooming in and out with the mouse scroll wheel. |
|
scrollWheelZoomEnabled() |
Boolean |
Returns true if mouse scroll wheel zooming is enabled, false otherwise. |
|
addControl(control) |
none |
Adds a control to the map, such as a PSmallMapControl. Click here for a list of available controls. |
smallmapcontrol.html |
removeControl(control) |
none |
Removes the given control from the map. |
|
hasControl(control) |
Boolean |
Returns true if control is added to the map, false if control is not on the map. |
hascontrol.html |
getContainer() |
Node |
Returns the DOM object (normally a div element) that contains the map. |
|
getCenter() |
PLatLng |
Returns a PLatLng object that represents the center point of the current map view in latitude/longitude. |
infowindow.html |
getBounds() |
PLatLngBounds |
Returns a PLatLngBounds object that represents the rectangular bounding box of the current map view in latitude/longitude. |
overlay.html |
getBoundsZoomLevel(bounds) |
Number |
Returns the maximum zoom level at which the given rectangular bounds can fit in the map view, for the current map type. |
|
getSize() |
PSize |
Returns the size of the map view in pixels. |
|
getZoom() |
Number |
Returns the zoom level of the current map. |
zoom.html |
setCenter(center, zoom) |
none |
Centers the map at the given center. If the zoom is specified, map zooms to the given zoom level. This method (or setCenterBounds) should be called first, right after a new PMap is declared, to set the initial map view. |
start.html |
setCenterBounds(bounds) |
none |
Centers the map at the maximum zoom level which the given rectangular bounds can fit in the map view. |
|
panTo(center) |
none |
Centers the map at the given center. If the point is within the current map view, the map will pan smoothly to the point. |
panto.html |
panBy(distance) |
none |
Pans smoothly by the given PSize distance in pixels. Negative width moves the map to the right (like dragging the map left), negative height moves the map down (like dragging the map up). |
panby.html |
panDirection(dx, dy) |
none |
Similar to panBy but pans smoothly by half the width and height of the map using -1, 0 or 1 as direction values for dx and dy. Negative direction (-1) moves the map to the right (dx) or down (dy). |
pandirection.html |
setZoom(level) |
none |
Zooms to the given level. If the zoom level is not valid, the request is ignored. |
zoom.html |
zoomIn() |
none |
Zooms in by one zoom level (+1). |
zoom.html |
zoomOut() |
none |
Zooms out by one zoom level (-1). |
zoom.html |
printImage(size, center, zoom) |
String |
Returns the URL of a single image of the current map type with the current size, center and zoom level of the map, unless the optional parameters are specified. |
printmap.html |
savePosition() |
none |
Stores the current map view (coordinates and zoom level). This can later be used by returnToSavedPosition to return to this view. |
saveposition.html |
returnToSavedPosition() |
none |
Returns to the map view that was saved by savePosition. Returns to the last result if no position was saved. |
saveposition.html |
addOverlay(overlay) |
none |
Adds the given PMarker or PPolyline overlay to the map. |
overlay.html |
removeOverlay(overlay) |
none |
Removes the given overlay (PMarker or PPolyline) from the map. |
click.html |
clearOverlays() |
none |
Removes all overlays from the map. |
|
openInfoWindow(point, node) |
none |
Displays an info window at the given point with the given HTML DOM node. |
infowindow.html |
openInfoWindowHtml(point, html) |
none |
Displays an info window at the given point with the given HTML string. |
|
openInfoWindowTabs(point, tabs) |
none |
Displays an info window at the given point with the given tabs (DOM nodes are used for the contents). |
|
openInfoWindowTabsHtml(point, tabs) |
none |
Displays an info window at the given point with the given tabs (HTML strings are used for the contents). |
|
closeInfoWindow() |
none |
Closes the info window if it is displayed on the map. |
|
getInfoWindow() |
PInfoWindow |
Returns the info window. |
getinfowindow.html |
fromLatLngToDivPixel(latlng) |
PPoint |
Converts the given geographical point in the map's DOM element into pixel coordinates, with (0,0) being the top left corner of the map view. |
latlngtopixel.html |
fromDivPixelToLatLng(pixel) |
PLatLng |
Converts the given pixel point in the map's DOM element into geographical coordinates, with (0,0) being the top left corner of the map view. |
latlngtopixel.html |
addOverlaySet(overlayset) |
none |
Adds the given POverlaySet to the map. |
addfilter.html |
removeOverlaySet(overlayset) |
none |
Removes the given POverlaySet from the map. |
|
clearOverlaySets() |
none |
Removes all overlay sets from the map. |
|
setOverlaySets(overlaysets) |
none |
Sets the array of overlay sets for the map. |
addset.html |
getOverlaySets() |
Array of POverlaySet |
Returns the array of overlay sets from the map. |
|
identify(point, callback, markerMax) |
none |
If using predefined server side markers with POverlaySet, this method can be used to see if any markers lie around the point given. An array of PMarkers will be returned via the callback function sorted by the closest markers to the point, if any. An optional markerMax parameter can be set to specify the maximum number of markers to return. The default is set to 20. |
addserverset.html |
setMapType(maptype) |
none |
Sets the map type for the map. Click here for a list of predefined map types. |
maptype.html |
getCurrentMapType() |
PMapType |
Returns the currently selected map type for the map. |
mergeclient.html |
setLegend(legend) |
none |
Sets the PLegend for the map. |
|
getLegend() |
PLegend |
Returns the PLegend for the map. |
colorramp.html |
setIndicator(indicator) |
none |
Sets and displays the given indicator on the map. The indicator has to first be loaded using PIndicatorLoader. Click here for a list of available indicators. |
thematic2.html |
setIndicatorById(id) |
none |
Sets and displays the indicator with the given id on the map. This is a quick way to add an indicator to the map that does not require PIndicatorLoader. However, the properties of the indicator will not be available within the same function. Click here for a list of available indicators. |
thematic.html |
removeIndicator() |
none |
Removes the current indicator from the map. |
|
getIndicator() |
PIndicator |
Returns the current indicator on the map. |
|
setIndicatorList(indicators) |
none |
Sets the array of PIndicator objects to be used with the indicator widget. The indicators have to first be loaded using PIndicatorLoader. |
|
setIndicatorListByIds(ids) |
none |
Sets the array of PIndicator objects to be used with the indicator widget with the given array of ids. This is a quick way to add indicators to the widget that does not require loading indicators with PIndicatorLoader. |
widgets.html |
getIndicatorList() |
Array of PIndicator |
Returns the array of PIndicator objects used with the indicator widget. |
|
| Event |
Argument |
Description |
Example |
click |
overlay, point
|
This event gets triggered when a mouse click happens on the map. The overlay argument will contain
a value if the user clicked on a marker and will be passed to the event handler. The latitude and longtiude of the click
will be passed as a PLatLng if no overlay was clicked. |
click.html |
movestart |
none |
This event gets triggered when the map view starts changing. This could happen from a pan, drag or a method that changes the map view. |
events.html |
move |
none |
This event gets triggered as the map view changes. |
|
moveend |
none |
This event gets triggered when the map view has finished changing. |
events.html |
zoomend |
none
|
This event gets triggered when the zoom level of the map has changed. |
events.html |
infowindowopen |
none |
This event gets triggered when the info window opens. |
|
infowindowclose |
none |
This event gets triggered when the info window closes. This includes the info window automatically closing when another window is opened. |
|
addoverlay |
overlay |
This event gets triggered when an overlay gets added to the map with addOverlay(). The overlay is passed as an argument to the event handler. |
|
removeoverlay |
overlay |
This event gets triggered when an overlay is removed from the the map with removeOverlay(). The overlay is passed as an argument to the event handler. |
|
clearoverlays |
none |
This event gets triggered when all overlays are removed from the the map with clearOverlays(). The removeoverlay event does not get triggered in this case. |
|
mousemove |
none |
This event gets triggered when the mouse is moved inside the map. |
|
dragstart |
none |
This event gets triggered when the map starts getting dragged. |
events.html |
drag |
none |
This event gets triggered as the map gets dragged. |
|
dragstop |
none |
This event gets triggered when the map stops being dragged. |
events.html |
Class: PInfoWindowTab |
| Method |
Return |
Description |
Example |
new PInfoWindowTab(label, content) |
PInfoWindowTab |
Creates a new info window tab with the given label and content. The content can be an HTML string or a DOM element. |
tabs.html |
Class: PMarker |
| Method |
Return |
Description |
Example |
new PMarker(point, icon) |
PMarker |
The constructor. Creates a new PMarker object at the given
point. A PIcon
can be specified, otherwise the default Pushpin icon will be used.
|
addpin.html
changeicon.html
|
openInfoWindow(content) |
none |
Displays an info window above the marker with the given HTML DOM element. |
|
openInfoWindowHtml(content) |
none |
Displays an info window above the marker with the given HTML string. |
infowinmarkup.html |
openInfoWindowTabs(tabs) |
none |
Displays an info window above the marker with the given tabs (DOM nodes are used for the contents). |
|
openInfoWindowTabsHtml(tabs) |
none |
Displays an info window above the marker with the given tabs (HTML strings are used for the contents). |
tabs.html |
getIcon() |
PIcon |
Returns the icon for this marker. |
|
getPoint() |
PLatLng |
Returns the point where this marker is anchored. |
|
setPoint(point) |
none |
Sets the point where this marker is to be anchored. |
|
addAttribute(attribute) |
none |
Adds the given attribute to this marker. |
addfilter.html |
removeAttribute(name) |
none |
Removes the attribute with the given name from this marker. |
|
getAttribute(name) |
PAttribute |
Returns the attribute with the given name from this marker. |
|
setAttributes(attributes) |
none |
Sets the given array of attributes to this marker. |
addfilterdisplay.html |
getAttributes() |
Array of PAttribute |
Returns the array attributes for this marker. |
|
| Event |
Argument |
Description |
Example |
click |
none |
This event gets triggered when a mouse click happens on the marker. |
infowinmarkup.html |
dblclick |
none |
This event gets triggered when a mouse double click happens on the marker. |
|
mousedown |
none |
This event gets triggered when a mousedown happens on the marker. |
|
mouseup |
none |
This event gets triggered when a mouseup happens on the marker. |
|
mouseover |
none |
This event gets triggered when a mouseover happens on the marker. |
|
mouseout |
none |
This event gets triggered when a mouseout happens on the marker. |
|
Class: PPolyline |
| Method |
Return |
Description |
Example |
new PPolyline(points, color, weight, opacity) |
PPolyline |
The constructor. Creates a new PPolyline object from the given points (array of PLatLng objects).
The color (in HTML hex form like "#ff0000"), weight (thickness in pixels), and opacity (value between 0 and 1) can be specified.
|
overlay.html |
getVertexCount() |
Number |
Returns the number of vertices (points) that the polyline contains. |
|
getVertex(index) |
PLatLng |
Returns the vertex (point) in the polyline with the given index. |
|
addAttribute(attribute) |
none |
Adds the given attribute to this polyline. |
|
removeAttribute(name) |
none |
Removes the attribute with the given name from this polyline. |
|
getAttribute(name) |
PAttribute |
Returns the attribute with the given name from this polyline. |
|
setAttributes(attributes) |
none |
Sets the given array of attributes to this polyline. |
|
getAttributes() |
Array of PAttribute |
Returns the array of attributes for this polyline. |
|
Class: PPolygon |
| Method |
Return |
Description |
Example |
new PPolygon(points, color, weight, opacity, fillColor) |
PPolygon |
The constructor. Creates a new PPolygon object from the given points (array of PLatLng objects).
The color (in HTML hex form like "#ff0000"), weight (thickness in pixels), and opacity (value between 0 and 1) can be specified for the border of the polygon (same as PPolyline). Additionally, you can specify a fillColor to shade the polygon.
|
overlay.html |
getVertexCount() |
Number |
Returns the number of vertices (points) that the polygon contains. |
|
getVertex(index) |
PLatLng |
Returns the vertex (point) in the polygon with the given index. |
|
Class: POverlaySet |
| Method |
Return |
Description |
Example |
new POverlaySet(overlays, manager) |
POverlaySet |
The constructor. Creates an overlay set containing the given array of overlays. Marker operations will be handled by a marker manager if specified (this means the overlays must only contain markers). |
addset.html |
new POverlaySet(id, icon, zoom, max) |
POverlaySet |
The constructor for creating a predefined marker set from the Pushpin catalog (specified by id), using server side rendering to achieve this when displaying large amounts of markers (in the thousands). Click here to see available point datasets in the catalog. The icon can be specified, otherwise PIcon.POINT will be used. The zoom determines when the rendering should switch to the client side, e.g. the default is 12 so it would render markers on the client side for zoom levels 12 and above. In addition, the max number of markers to be displayed on the client side can be set as well, the default is 50 (e.g. if more than 50 pins show on the map, it would always render the markers on the server). |
addserverset.html |
setLabel(label) |
none |
Sets the label for this overlay set. |
addset.html |
getLabel() |
String |
Returns the label for this overlay set. |
|
addOverlay(overlay) |
none |
Adds the given overlay to this overlay set. If the set is turned on, then the overlay gets added to the map. |
|
removeOverlay(overlay) |
none |
Removes the given overlay from this overlay set. If the set is turned on, then the overlay gets removed from the map. |
|
getOverlays() |
Array of PMarker or PPolyline |
Returns the array of overlays in this overlay set. If filters are set, this returns the filtered overlays. |
|
getOverlayCount() |
Number |
Returns the number of overlays in this overlay set. If filters are set, this returns the number of filtered overlays. If using predefined server side markers, this returns the number of markers in the map view. |
|
on() |
none |
Turns on this overlay set. This adds the overlays on the map. |
|
off() |
none |
Turns off this overlay set. This removes the overlays from the map. |
addset.html |
isOn() |
Boolean |
Returns true if this overlay set is on, false otherwise. |
|
addFilter(filter) |
none |
Adds the given filter to this overlay set and refreshes and displays the filtered overlays on the map if this set is turned on. |
addfilter.html |
removeFilter(filter) |
none |
Removes the given filter from this overlay set and refreshes the overlays on the map if this set is turned on. |
|
clearFilters() |
none |
Removes all filters from this overlay set and refreshes the overlays on the map if this set is turned on. |
addfilter.html |
setFilters(filters) |
none |
Sets the given array of filters to this overlay set and refreshes the overlays on the map if this set is turned on. |
|
getFilters() |
Array of PAttributeFilter |
Returns the array of filters for this overlay set. |
|
setDisplayFilters(filters) |
none |
Sets the array of filters to be displayed for choosing if the overlay widget is used. The array order is the order of display. |
addfilterdisplay.html |
Class: PIcon |
| Method |
Return |
Description |
Example |
new PIcon(icon) |
PIcon |
The constructor. Creates a new PIcon object. If a PIcon is specified,
its properties are copied. Click here for a list of predefined Pushpin icons.
|
icon.html |
| Property |
Type |
Description |
Example |
image |
String |
The URL of the icon image to be used. |
icon.html |
shadow |
String |
The URL of the icon's shadow image to be used. |
icon.html |
iconSize |
PSize |
The size of the icon image in pixels. |
icon.html |
shadowSize |
PSize |
The size of the icon's shadow image in pixels. |
icon.html |
iconAnchor |
PPoint |
The offset for the icon in pixels, to anchor the icon to the marker's point. |
icon.html |
shadowAnchor |
PPoint |
The offset for the shadow in pixels, to anchor the shadow to the marker's point. |
icon.html |
infoWindowAnchor |
PPoint |
The offset for the info window in pixels, to anchor the info window to the marker's point. |
icon.html |
Class: PEvent |
| Method |
Return |
Description |
Example |
addListener(source, event, handler) |
none |
A static method that calls the given function when the given event happens on the source object. |
infowinmarkup.html |
Class: PClientGeocoder |
| Method |
Return |
Description |
Example |
new PClientGeocoder() |
PClientGeocoder |
The constructor. Creates an object that can convert address strings into a latitude and longitude coordinates. |
geocode.html |
getLatLng(address, callback) |
none |
Calls the Pushpin geocoder to geocode an address and return the result via the callback function. If the address is found, the result returned is a PLatLng, otherwise null is returned. |
geocode.html |
getLocations(address, callback) |
none |
Calls the Pushpin geocoder to geocode an address and return the result via the callback function. The result returned is a PAddress. |
geocode2.html |
getPlace(search, callback, maxResults, order, placeTypes) |
none |
Searches for the search string given and returns an array of PPlace objects that match the string via the callback function. The maxResults argument can be specified to limit the number of PPlace objects returned in the array when more than one result is found (default is 10).
The order can also be specified with a PPlaceOrder object e.g. AREA (default -- orders by largest place first) or LABEL (order by the place name/label). The placeTypes array can also be specified to restrict the results only by the types in the array.
Click here for a list of place types.
|
findplace.html |
Class: PPlace |
| Method |
Return |
Description |
Example |
getID() |
Number |
Returns the distinct id of this place. PPlace is usually not instantiated and gets returned by various function calls like PClientGeocoder.getPlace(). |
|
getLabel() |
String |
Returns display name for this place. |
findplace.html |
getType() |
PPlaceType |
Returns the place type. |
findplace.html |
getBounds() |
PLatLngBounds |
Returns the bounding box for the place. |
findplace.html |
getCentroid() |
PLatLng |
Returns the centroid of the place. |
|
getArea() |
Number |
Returns the area of this place in square meters. |
|
getPopulation() |
Number |
Returns the population of this place. |
|
getState() |
String |
Returns the abbreviated state for this place (USA). |
findplace.html |
getVertices() |
Array of PLatLng Arrays |
Returns an array of PLatLng arrays to symbolize simplified groups of vertices (some boundaries have multiple polygons) for this place. This can be used with PPolyline or PPolygon to highlight the geography of the place. |
findplace.html |
getIdentifier() |
String |
Returns the standard identifier of this place, e.g. "06037" for Los Angeles County |
|
Class: PAddress |
| Method |
Return |
Description |
Example |
new PAddress(addr, x, y, errorMsg, errorCode) |
PAddress |
The constructor. Creates an object that stores an address and its coordinates if it was geocoded. See the PGeocoder class. |
geocode2.html |
wasFound() |
Boolean |
Returns true if the address was geocoded successfully (i.e. the x and y properties of the object have values); false otherwise. |
geocode2.html |
| Property |
Type |
Description |
Example |
addr |
String |
Calls the pushpin geocoder to geocode the address and return the result via callback. The address argument must be a PAddress object. The callback argument must be a Function that accepts a PAddress as its first argument. |
geocode2.html |
x |
Number |
The longitudinal coordinate of the address. |
geocode2.html |
y |
Number |
The latitudinal coordinate of the address. |
geocode2.html |
errorMsg |
String |
User-friendly text describing why an error ocurred in geocoding the address. |
geocode2.html |
errorCode |
Number |
A number indicating the type of error that occurred when geocoding the address. |
geocode2.html |
Class: PMarkerManager |
| Method |
Return |
Description |
Example |
new PMarkerManager(map, icon) |
PMarkerManager |
The constructor. Creates a new PMarkerManager object to control the number of markers visible at one time in the given map by grouping markers into clusters. If an icon is specified, that icon is used for the cluster of markers, otherwise the default icon is used. Click here for a list of predefined icons. |
markermanager.html |
addMarkers(markers) |
none |
Adds the given array of markers to the map. |
|
addMarker(marker) |
none |
Adds the given marker to the map. |
markermanager.html |
removeMarker(marker) |
none |
Removes the given marker from the map. |
|
clearMarkers() |
none |
Removes all markers added by this marker manager from the map. |
clearmarkers.html |
getIcon() |
PIcon |
Returns the cluster icon used by this marker manager. |
|
setMaxVisibleMarkers(number) |
none |
Sets the maximum number of visible markers to be displayed on the map view at one time. The default is 150. |
|
setMinMarkersPerCluster(number) |
none |
Sets the minimum number of markers that is required to be grouped into a cluster. The default is 5. |
|
Class: PPoint |
| Method |
Return |
Description |
Example |
new PPoint(x, y) |
PPoint |
The constructor. Creates a new PPoint object with the x and y coordinates in pixels. |
icon.html |
equals(other) |
Boolean |
Returns true if the given point has equal coordinates, false otherwise. |
|
toString() |
String |
Returns a string representation of this point with the x and y values separated by a comma and surrounded by parentheses. |
|
| Property |
Type |
Description |
Example |
x |
Number |
The x coordinate value in pixels. |
|
y |
Number |
The y coordinate value in pixels. |
|
Class: PSize |
| Method |
Return |
Description |
Example |
new PSize(width, height) |
PSize |
The constructor. Creates a new PSize object with the given width and height measurement values. This could be in longitude (width) or latitude (height) or in pixels. |
icon.html |
equals(other) |
Boolean |
Returns true if the given PSize is equal, false otherwise. |
|
toString() |
String |
Returns a string representation with the width and height values separated by a comma and surrounded by parentheses. |
|
| Property |
Type |
Description |
Example |
width |
Number |
The width value. |
|
height |
Number |
The height value. |
|
Class: PBounds |
| Method |
Return |
Description |
Example |
new PBounds(minX, minY, maxX, maxY) |
PBounds |
The constructor. Creates a new PBounds object with the given coordinates in pixels that represent a rectangle. minX, minY represent the top left coordinates of the rectangle and maxX, maxY represent the bottom right coordinates.
|
overlay.html |
toString() |
String |
Returns a string representation with the top left and bottom right coordinates separated by a comma and surrounded by parentheses. |
|
min() |
PPoint |
Returns a PPoint of the top left coordinate. |
|
max() |
PPoint |
Returns a PPoint of the bottom right coordinate. |
|
containsBounds(other) |
Boolean |
Returns true if the given PBounds rectangle is contained within this rectangle, false otherwise. |
|
extend(point) |
none |
Enlarges this PBounds rectangle to contain the given point, if the point lies outside the bounds. |
|
| Property |
Type |
Description |
Example |
minX |
Number |
The x coordinate value of the left point of the rectangle in pixels. |
|
minY |
Number |
The y coordinate value of the top point of the rectangle in pixels. |
|
maxX |
Number |
The x coordinate value of the right point of the rectangle in pixels. |
|
maxY |
Number |
The y coordinate value of the bottom point of the rectangle in pixels. |
|
Class: PLatLng |
| Method |
Return |
Description |
Example |
new PLatLng(lat, lng) |
PLatLng |
The constructor. Creates a new PLatLng object with the lat and lng coordinates in degrees. |
start.html |
lat() |
Number |
Returns the latitude coordinate in degrees. |
overlay.html |
lng() |
Number |
Returns the longitude coordinate in degrees. |
overlay.html |
latRadians() |
Number |
Returns the latitude coordinate in radians. |
|
lngRadians() |
Number |
Returns the longitude coordinate in radians. |
|
equals(other) |
Boolean |
Returns true if the coordinates of two points are identical. |
|
distanceFrom(other) |
Number |
Returns the estimated distance in meters from this point to the other one. The number returned is always positive. |
distance.html |
toString() |
String |
Returns a string representation of this point with the lat and lng values separated by a comma and surrounded by parentheses. |
|
Class: PLatLngBounds |
| Method |
Return |
Description |
Example |
new PLatLngBounds(sw, ne) |
PLatLngBounds |
A constructor. Creates a new PLatLngBounds object with the given south-west and north-east points that represent a rectangle. |
overlay.html |
new PLatLngBounds(center, radius) |
PLatLngBounds |
A constructor. Creates the smallest PLatLngBounds object that covers the dimensions of the circle defined by the parameters. The bounds rectangle is centered on the center parameter. The radius parameter should be a distance in meters from the center to the edge of the circle. |
distancezoom.html |
contains(latlng) |
Boolean |
Returns true if the point lies within the rectangle, false otherwise. |
|
containsBounds(other) |
Boolean |
Returns true if the given PLatLngBounds rectangle is contained within this rectangle, false otherwise. |
|
extend(latlng) |
none |
Enlarges this PLatLngBounds rectangle to contain the given point, if the point lies outside the bounds. |
|
getSouthWest() |
PLatLng |
Returns the south-west point of the rectangle. |
overlay.html |
getNorthEast() |
PLatLng |
Returns the north-east point of the rectangle. |
overlay.html |
toSpan() |
PLatLng |
Returns a PLatLng that represents the size of the rectangle. |
|
isEmpty() |
Boolean |
Returns true if this PLatLngBounds rectangle is empty, false otherwise. |
|
getCenter() |
PLatLng |
Returns the center point of the rectangle. |
|
toString() |
String |
Returns a string representation with the south-west and north-east coordinates separated by a comma and surrounded by parentheses. |
|
Class: PAttribute |
| Method |
Return |
Description |
Example |
new PAttribute(name, value, type) |
PAttribute |
The constructor. Creates a new PAttribute object with the given name, value and type. The value argument must be of the type given in the type argument. Click here for a list of supported types. |
addfilter.html |
| Property |
Type |
Description |
Example |
name |
String |
The name of this attribute. |
|
value |
Variable |
The value for this attribute. |
addfilter.html |
type |
Number |
The type for this attribute, e.g. PAttribute.NUMBER. The value property must be of this type. Click here for a list of supported types. |
|
columnName |
String |
The column name that gets returned when using a predefined POverlaySet. |
|
Class: PAttributeFilter |
| Method |
Return |
Description |
Example |
new PAttributeFilter(name, values, type, valuesDisplay, columnName, columnType) |
PAttributeFilter |
The constructor. Creates a new PAttributeFilter object with the given name of the attribute, values and type. The values in the values array must be of the type of the attribute. Set the optional parameter valuesDisplay with the label display for the filter in the filter widget. If using a predefined server side POverlaySet, you need to specify the columnName and columnType as well. |
addfilter.html addserverset.html |
| Property |
Type |
Description |
Example |
name |
String |
The name of the attribute to filter. |
|
values |
Array of Variable |
The value(s) to filter the attribute by. |
|
type |
Number |
The filter type to apply on the attribute with the value(s), e.g. PAttributeFilter.EQUAL. Click here for a list of supported types. |
|
valuesDisplay |
String |
The display of the filter values (shows up in the overlay set filter widget). If not specified, a standard default way of displaying the values will be used. |
|
columnName |
String |
The column name of the attribute to filter, if using a predefined POverlaySet |
|
columnType |
Number |
The column attribute type, e.g. PAttribute.NUMBER, if using a predefined POverlaySet. Click here for a list of supported types. |
|
Class: PXmlHttp |
| Method |
Return |
Description |
Example |
create() |
PXmlHttp |
A static method that creates a new instance of a browser independent XmlHttpRequest object. |
|
Class: PXml |
| Method |
Return |
Description |
Example |
parse(xmltext) |
Node |
A static method that parses the given XML text and returns a DOM node. |
xml.html |
value(xmlnode) |
String |
A static method that returns the text of the XML document fragment given as a DOM node. |
xml.html |
Class: PXslt |
| Method |
Return |
Description |
Example |
new PXslt(xsltnode) |
PXslt |
The constructor. Creates a PXslt object from the XSLT stylesheet given as a DOM node. |
|
transformToHtml(xmlnode, htmlnode) |
Boolean |
Returns true and applies the XSLT stylesheet from this PXslt object to the the given XML document given as a DOM node and appends the resulting HTML document element to the given HTML node, if this is supported in the browser. If not, the function will do nothing and return false. |
|
Class: PLargeMapControl |
| Method |
Return |
Description |
Example |
new PLargeMapControl() |
PLargeMapControl |
The constructor. Creates large zoom and pan controls on the map, including the zoom slider. |
largecontrol.html |
Class: PSmallMapControl |
| Method |
Return |
Description |
Example |
new PSmallMapControl() |
PSmallMapControl |
The constructor. Creates small zoom and pan controls on the map. |
smallmapcontrol.html |
Class: PSmallZoomControl |
| Method |
Return |
Description |
Example |
new PSmallZoomControl() |
PSmallZoomControl |
The constructor. Creates only a small zoom control.. |
smallcontrol.html |
Class: PMapTypeControl |
| Method |
Return |
Description |
Example |
new PMapTypeControl() |
PMapTypeControl |
The constructor. Creates a map type control on the map for toggling between the normal map (PMapType.NORMAL), satellite (PMapType.SATELLITE) and hybrid (PMapType.HYBRID). |
|
|